Develop a limited app. to track a person’s first name, last name, and age. Desig
ID: 3628833 • Letter: D
Question
Develop a limited app. to track a person’s first name, last name, and age.Design and implement an object to record the info. Use Scanner methods and an ArrayList for storage. using java class Human
Application should allow:
-person to Add new human
-Delete human- prompting user for last name
-Display human list with first/last name and age and average age of human(s) in list
-Save the output to a file, prompt user for filename
-End the application.
-Prompted (Add, Delete, Display, Save, End)
Example output:
What operation next? (Add, Delete, Display, Save, End)? Add
Please enter Hunam's Last name: Doe
Please enter Human's First name: Jane
Please enter Human's Age: 43
Added!
Jane Doe: Age: 43
What operation next...
So far I have in my player class
private String lastName;
private String firstName;
private int age;
//have for each last name, first and age
public void setLastname(String last){
}
public void getLastName(){
return lastName;}
This is my first time programming something with a main and class.. I do not understand how to incorporate both. My professor confuses me and my book does not display good examples for me to understand. Thanks!
Explanation / Answer
1- You need to use Import util.java*. to use Scanner 2- to user Scanner you create it like: Scanner input=new Scanner(System.in); 3-U need an Array (not sure how many dimenstions) System.out.println("What do you want to do? add,delete,save,end?) String request=input.nextln(); //this will hold what command the user chose String fanem; //first name Sting lname; //last name int age; // age of person (use 2d array) 4-take the command the user asked and use (if statements) if(request.equals(add)) { System.out.println("Enter first name"); fname=input.nextline(); then for the last name, and the age don't 4get the age user nextint then u could save the values wi to array using for loop to address each position of array for the value the user cereated. for command deleteu ask for name and last name if it is in the array delete them the same way with for loop and bolan condition. } else if and so on 5- it is hard to tell u the rest, but u use another import tools to help u u save the array and output it to a text file. I'm orry If i was awake I would done this for you, but I have class at 8:30 it is 2 now :(
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.