Question: Write a JAVA program People which reads an input of lines, where each line contains a name (String), an age (int), and a weight (double),
Write a JAVA program People which reads an input of lines, where each line contains a name (String),
an age (int), and a weight (double), until it reaches a line that contains only the string "stop".
You can safely assume that there will be at least one line of input before the "stop" string.
The program should then store the data in in an ArrayList called People, where each element of
the ArrayList is an Object containing a name, age, and weight. Always add new Objects to the end
of the ArrayList.
You'll need to create a separate class called Person with appropriate private variables. You'll
need set and get functions for each variable. The program should loop through the elements of
People and print out the contents of each element separated by a space - yes, it will almost
look exactly like the input!
INPUT
Samuel 1 123ENTER Sammie 2 234ENTER Sammy 3 345ENTER Sam 4 456ENTER I 5 567ENTER Am 6 678ENTER stopENTER
OUTPUT Samuel 1 123.0 Sammie 2 234.0 Sammy 3 345.0 Sam 4 456.0 I 5 567.0 Am 6 678.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
