I have tried the following code:
import java.util.Scanner;
public class PeopleWeights {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.println("Enter weight 1: " + reader.nextDouble());
double weightOne = reader.nextDouble();
System.out.println("Enter weight 2: " + reader.nextDouble());
double weightTwo = reader.nextDouble();
System.out.println("Enter weight 3: " + reader.nextDouble());
double weightThree = reader.nextDouble();
System.out.println("Enter weight 4: " + reader.nextDouble());
double weightFour = reader.nextDouble();
System.out.println("Enter weight 5: " + reader.nextDouble());
double weightFive = reader.nextDouble(); /* Type your code here. */
return;
}
}
I am sorry if my point of confusion is all over the place. But in short I'm having trouble with:
Enter weight 1:
236.0
Enter weight 2:
89.5
Enter weight 3:
142.0
Enter weight 4:
166.3
Enter weight 5:
93.0
You entered: 236.0 89.5 142.0 166.3 93.0
At first create an array:
// create array of doubles including 5 fields
double[] MyArray = new double[5];
And use for loop to iterate over it and store values in it:
for(int x = 0; x < MyArray.length; x = x + 1)
{
System.out.println("Enter value: ");
MyArray[x] = reader.nextDouble();
}