estefania

how do u add the elements?

this is my program

[CODE]import java.util.Scanner;

public class RandomNumbers
{
public static void main(String [] args)
{
Scanner scan= new Scanner(System.in);

int pos, value;

System.out.println("Enter value of numbers to generate(0-100): ");
value=scan.nextInt();

while (value<0 || value>100)
{
System.out.println("Please enter value again (0-100): ");
}   
    double[]random =new double[value];

    for (pos=0; pos< value; pos++)
    {
    random[pos]=Math.random()*1000.0 + 17.5;
    }

    System.out.println("Here are the random numbers: ");
    for (pos=0; pos<value; pos++)
    System.out.println(random[pos]);    

}

}
[/CODE]

i need to generate the sum of the random numbers.

estefania Newbie Poster

Hi, how do u calculate the sum of the numbers in the array?

Thanks!