Storing details from an input and displaying all the details with each new
input. (Java)
I have a problem with figuring out how to approach this code. I am trying
to prompt the user for details of a person (such as name, age and
telephone number) and then output all person information. Whenever another
person's information is inputted, the information of the person before
hand as well as the current one is outputted.
Should look like this:
My Input: Adam, 25, 12345678, France
Output: Adam, 25, 12345678, France
My Input Second time: Bob, 22, 12345678, Australia
Output second time:
Adam, 25, 12345678, France
Bob, 22, 12345678, Australia
And so forth say 10 times which would create the table the tenth time with
all details. Any ideas on how I can do the whole create the table each
time with more details? I've tried this to store variables but maybe
looping an array is better? I'm new to Java as I've only picked it up
recently. Any examples would be much appreciated. Thanks a heap!
Scanner scan = new Scanner(System.in);
scan.useDelimiter(",");
String sName = scan.next();
System.out.println(header);
String sLast = scan.next();
double sData1 = scan.nextDouble();
double sData2 = scan.nextDouble();
double sData3 = scan.nextDouble();
int sData4 = scan.nextInt();
No comments:
Post a Comment