Saturday, 24 August 2013

How do I create a list of user inputs?

How do I create a list of user inputs?

I am coding in Java and I have to create a program that accepts user
input, which I have done. But I am confused as to what statement I can use
to list those integer input by the user.
This is what I have so far:
//Biker's Journey Program
import java.util.Scanner;
public class lab2
{
public static void main( String[] args )
{
Scanner input = new Scanner( System.in);
int w;
int x;
int y;
int z;
int result;
System.out.print("Please enter the first day's traveled miles: ");
w = input.nextInt();
System.out.print("Please enter the second day's traveled miles: ");
x = input.nextInt();
System.out.print("Please enter the third day's traveled miles: ");
y = input.nextInt();
System.out.print("Please enter the last day's traveled miles: ");
z = input.nextInt();
System.out.print("The number of miles traveled was: ");
System.out.println()
result = (w + x + y + z) / 4;
System.out.printf("The average miles per day traveled is %d\n", result);
}
}
And this segment of code does the computing, I just can not figure out how
to get the integers listed like this this picture:
http://imgur.com/KFNkWEd

No comments:

Post a Comment