Answer:
import java.util.Scanner;
public class PeopleWeights {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
double weightOne = reader.nextDouble();
System.out.println("Enter 1st weight:");
double weightTwo = reader.nextDouble();
System.out.println("Enter 2nd weight :");
double weightThree = reader.nextDouble();
System.out.println("Enter 3rd weight :");
double weightFour = reader.nextDouble();
System.out.println("Enter 4th weight :");
double weightFive = reader.nextDouble();
System.out.println("Enter 5th weight :");
double sum = weightOne + weightTwo + weightThree + weightFour + weightFive;
double[] MyArr = new double[5];
MyArr[0] = weightOne;
MyArr[1] = weightTwo;
MyArr[2] = weightThree;
MyArr[3] = weightFour;
MyArr[4] = weightFive;
System.out.printf("You entered: " + "%.1f %.1f %.1f %.1f %.1f ", weightOne, weightTwo, weightThree, weightFour, weightFive);
double average = sum / 5;
System.out.println();
System.out.println();
System.out.println("Total weight: " + sum);
System.out.println("Average weight: " + average);
double max = MyArr[0];
for (int counter = 1; counter < MyArr.length; counter++){
if (MyArr[counter] > max){
max = MyArr[counter];
}
}
System.out.println("Max weight: " + max);
}
import java.util.Scanner;
public class PeopleWeights {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
double weightOne = reader.nextDouble();
System.out.println("Enter 1st weight:");
double weightTwo = reader.nextDouble();
System.out.println("Enter 2nd weight :");
double weightThree = reader.nextDouble();
System.out.println("Enter 3rd weight :");
double weightFour = reader.nextDouble();
System.out.println("Enter 4th weight :");
double weightFive = reader.nextDouble();
System.out.println("Enter 5th weight :");
double sum = weightOne + weightTwo + weightThree + weightFour + weightFive;
double[] MyArr = new double[5];
MyArr[0] = weightOne;
MyArr[1] = weightTwo;
MyArr[2] = weightThree;
MyArr[3] = weightFour;
MyArr[4] = weightFive;
System.out.printf("You entered: " + "%.1f %.1f %.1f %.1f %.1f ", weightOne, weightTwo, weightThree, weightFour, weightFive);
double average = sum / 5;
System.out.println();
System.out.println();
System.out.println("Total weight: " + sum);
System.out.println("Average weight: " + average);
double max = MyArr[0];
for (int counter = 1; counter < MyArr.length; counter++){
if (MyArr[counter] > max){
max = MyArr[counter];
}
}
System.out.println("Max weight: " + max);
}