java.
I am having an issue with my lab is there someone who can help me with this Lab.
import java.text.DecimalFormat;
import java.util.Scanner;
public class PeopleWeights {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int i = 0;
int n = 5;
double arr[] = new double[n];
for (i = 0; i < n; ++i){
System.out.println(“Enter weight ” + (i + 1) + “: “);
arr[i] = scnr.nextDouble();
}
System.out.println();
System.out.print(“You entered:”);
for (i = 0; i < n; ++i) {
System.out.print(arr[i] + ” “);
}
double total = 0;
double max = 0;
for (i = 0; i < n; ++i){
if(max > arr[i]){
max = arr[i];
}
total = total + arr[i];
}
System.out.println();
DecimalFormat df = new DecimalFormat(“#.##”);
DecimalFormat df2 = new DecimalFormat(“#.##############”);
double average = total/n;
System.out.println(“Total weight: “+df.format(total));
System.out.println(“Average weight: “+df2.format(average));
System.out.println(“Max weight: “+ (max));
return;
}
}
"Looking for a Similar Assignment? Order now and Get 10% Discount! Use Code "Newclient"
