Question: Having some problems with my code with spacing as well as output. PeopleWeights.java import java.util.Scanner; public class PeopleWeights { public static void main(String[] args) {

 Having some problems with my code with spacing as well as

Having some problems with my code with spacing as well as output.

PeopleWeights.java

import java.util.Scanner;

public class PeopleWeights { public static void main(String[] args) { double[] weights = new double[5]; int i; double total = 0, average, max = 0; Scanner sc = new Scanner(System.in); for (i=0; imax) max = weights[i];

System.out.println(" "); average = total/5; System.out.println("Total weight:" + total); System.out.println("Average weight:" + average); System.out.println("Max weight:" + max); return; } }

Exception in thread "main" java.lang.ArrayIndexOutofBoundsException: Index 5 out of bounc at PeopleWeights.main (PeopleWeights.java:21) Output differs. See highlights below. Special character legend

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!