public class Average {   /** * @param args */   publicstaticvoid main(String[] args) {   Scanner input = new Scanner(System.in);   System.out.print("Enter the number of classes: "); intnumClasses = input.nextInt();   int[] numStudents = newint[numClasses]; inttotalStudents = 0;   for (inti = 0; i < numClasses; i++) { System.out.print("Enter the number of students in class " + (i + 1) + ":"); numStudents[i] = input.nextInt(); totalStudents += numStudents[i]; }   intaverageStudents = totalStudents / numClasses;   System.out.println("The average number of students per class is " + averageStudents); System.out.println();   System.out.println("Class\tNumber of Students"); for (inti = 0; i < numClasses; i++) { System.out.print((i + 1) + "\t\t" + numStudents[i]); } } }   Write a Java program that solves the following problem. Name your class Average. Your program will determine the average number of students per class in a school. It should begin by requesting the number of classes in the school. It will then create an array and ask for the number of students in each class, storing those values in the array. The program will then print out a report that gives the average, followed by the information about each class. See the sample below for the exact format. Note that we are writing this for users, not programmers, so we are going to start counting at one for the displays to the user. Writing your entire program in main is fine.       Please enter the number of classes: 4 Enter the size of class 1: 20 Enter the size of class 2: 15 Enter the size of class 3: 24 Enter the size of class 4: 23   The average class size is 20. Class                     Number of Students 1                                           20 2                                           15 3                                           24 4                                           23   Can you help me fix above code so it match the sample output in Java

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

public class Average

{

 

/**

* @param args

*/

 

publicstaticvoid main(String[] args)

{

 

Scanner input = new Scanner(System.in);

 

System.out.print("Enter the number of classes: ");

intnumClasses = input.nextInt();

 

int[] numStudents = newint[numClasses];

inttotalStudents = 0;

 

for (inti = 0; i < numClasses; i++)

{

System.out.print("Enter the number of students in class " + (i + 1) + ":");

numStudents[i] = input.nextInt();

totalStudents += numStudents[i];

}

 

intaverageStudents = totalStudents / numClasses;

 

System.out.println("The average number of students per class is " + averageStudents);

System.out.println();

 

System.out.println("Class\tNumber of Students");

for (inti = 0; i < numClasses; i++)

{

System.out.print((i + 1) + "\t\t" + numStudents[i]);

}

}

}

 

Write a Java program that solves the following problem. Name your class Average. Your program will determine the average number of students per class in a school. It should begin by requesting the number of classes in the school. It will then create an array and ask for the number of students in each class, storing those values in the array. The program will then print out a report that gives the average, followed by the information about each class. See the sample below for the exact format. Note that we are writing this for users, not programmers, so we are going to start counting at one for the displays to the user. Writing your entire program in main is fine.

 

 

 

Please enter the number of classes: 4

Enter the size of class 1: 20

Enter the size of class 2: 15

Enter the size of class 3: 24

Enter the size of class 4: 23

 

The average class size is 20.

Class                     Number of Students

1                                           20

2                                           15

3                                           24

4                                           23

 

Can you help me fix above code so it match the sample output in Java

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education