Question: The following program declares an array with five values already initialized. The program then calculates the average of the values and outputs it to the

 The following program declares an array with five values already initialized. The program then calculates the average of the values and outputs it to the screen.

Scanner keyedInput = new Scanner (System.in); double [ ] marks = {34.7, 54.1, 34.8, 99.6, 43.6, 43.2}; double total=0; double average; System.out.println("These are the marks:"); for (int i = 0; i<=5; i= i + 1) { System.out.println(marks[i]); } for (int i = 0; i<=5; i= i + 1) { total = total + marks[i]; } average = total/6; average = average * 10; average = Math.round(average); average = average/10; System.out.println("The average mark is:"); System.out.println(average);

Alter the program so that the following marks are added to the list: 65.8, 44.8, 88.6.

The program should then output a new,corrected average.

- Please make sure that arrays are used

- Make sure this code works with Java 12.5 I Use Java with Maven

- Thank you for your help

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import javautilScanner public class AverageCalculator public ... View full answer

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 Programming Questions!