I am currently struggling with finishing this code. I am reviewing for my test tomorrow so any help is good!
The instructions on what to do are in the comments in the code.
I'm not sure if any of the stuff I have done in this code is valid honestly. My main issue currently though is figuring out how to calculate the sum of the 10 people. Could y'all help?
package Fall15Test3;
import java.util.*;
public class Person {
String name;
int age;
public Person(String name, int age) {
}
public void setName(String name) {
}
public String getName() {
return name;
}
public void setAge(int age) {
}
public int getAge() {
return age;
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//Create the array of 10 Person objects.
Person[] personArray = new Person[10];
//Initialize the array of persons using user's inputs.
for (int i = 0; i < personArray.length; i++) {
System.out.print("Please input name: ");
String name = input.nextLine();
System.out.print("Please input age: ");
int age = input.nextInt();
personArray[i] = new Person(name, age);
}
//Calculate the sum of the ages of the 10 people.
int ageTotal = 0;
for (int i = 0; i < personArray.length; i++) {
ageTotal += WHAT DO I PUT HERE;
}
System.out.println(ageTotal);
}
}