[Java] Main.java

less than 1 minute read

mport java.util.Scanner;

class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.print (“How many people do you want to enter:”);
int n = scanner.nextInt();

int maxAge = 0;
int totalAge = 0;
for(int i = 0; i < n; i++){  System.out.println (i + 1 + "eye");

System.out.print (“name:”);
String firstName = scanner.next();

System.out.print (“Last Name:”);
String lastName = scanner.next();

System.out.print (“age:”);
int age =scanner.nextInt();

  if(age >maxAge){
    maxAge = age;
  }
  totalAge += age;

System.out.print (“height (m):”);
double height = scanner.nextDouble();

System.out.print (“Weight (kg):”);
double weight = scanner.nextDouble();

  Person.printData(firstName,lastName,age,height,weight);
  }  System.out.println ("Maximum age is" + maxAge + "years old");  System.out.println ("Average age is" + totalAge / n + "years old");
}

}

Tags:

Updated: