Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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
Check Mark
Knowledge Booster
Background pattern image
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
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education