Question

In: Computer Science

DESCRIPTION Create a program to calculate and print basic stats on a set of a given...

DESCRIPTION

Create a program to calculate and print basic stats on a set of a given input values representing students' scores on an exam.

1) Ask the user for the total number of exam scores to be input (assume a positive integer will be given).

2) Create an array to hold all the exam scores and then get all the scores from input to put into the array. For example, if the user input 10 in step (1) then you should create an array to hold 10 double values (each of the 10 exam scores) and ask the user for the 10 values, one-by-one, to put in each spot.

3) Calculate and print the average (mean) score.

4) Print out a table displaying the number of each letter grade in the set of scores. Assign grades of A for scores of 90 and above, B for scores of 80 and above (but below 90), C for scores of 70 and above (but below 80), D for scores of 60 and above (but below 70), and F for scores below 60.

Sample output of program:

How many exam scores?
10
Enter the 10 exam scores:
95.6
98
100
96
84.2
82
80
77
66
62.1
Average score: 84.09
Grade - Count:
A - 4
B - 3
C - 1
D - 2
F - 0

Starter Code:-

import java.util.Scanner;

public class ExamStats {
public static void main(String[] args) {
//TODO: Complete the program
  
}
}

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new java program with name "ExamStats.java" is created, which contains following code.

ExamStats.java :

import java.util.Scanner;
public class ExamStats {

   public static void main(String[] args) {
       //creating object of Scanner class
       Scanner sc=new Scanner(System.in);
       //Asking user to enter number of Scores
       System.out.print("Enter Number of exam scores : ");
       //reading exam scores
       int examScore=sc.nextInt();
       //declaring array to store exam scores
       double [] examScores=new double[examScore];
       //using for loop to read and store exam score in the array examScores
       for(int i=0;i<examScore;i++)
       {
           //asking to enter exam scores
           System.out.print("Enter "+(i+1)+" exam score : ");
           //reading score
           examScores[i]=sc.nextDouble();
       }
       //declaring variables to count the grades
       int A=0,B=0,C=0,D=0,F=0;
       double sum=0;
       for(int j=0;j<examScore;j++)
       {
           //calculating sum
           sum=sum+examScores[j];
           //if exam score is > 90
           if(examScores[j]>=90)
           {
               A++;//increment count for grade A
           }
           //if exam score is > 80 and <90
           else if(examScores[j]>80 && examScores[j] <90 )
           {
               B++;//increment count for grade B
           }
           //if exam score is > 70 and <80
           else if(examScores[j]>70 && examScores[j] <80 )
           {
               C++;//increment count for grade C
           }
           //if exam score is > 60 and <70
           else if(examScores[j]>=60 && examScores[j] <70 )
           {
               D++;//increment count for grade D
           }
           //if exam score is < 60
           else if(examScores[j] <60 )
           {
               F++;//increment count for grade F
           }
       }
       //display details
       System.out.println("Average : "+(sum/examScore));
       //display grade and count
       System.out.println("Grade\tCount");
       System.out.println("A\t\t"+A);
       System.out.println("B\t\t"+B);
       System.out.println("C\t\t"+C);
       System.out.println("D\t\t"+D);
       System.out.println("F\t\t"+F);
      

   }

}

======================================================

Output : Compile and Run above program to get the screen as shown below

Screen 1 :ExamStats.java

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

Create a program to input the length and width of a rectangle and calculate and print...
Create a program to input the length and width of a rectangle and calculate and print the perimeter and area of the rectangle. To do this you will need to write a Rectangle class and a separate runner class. Your program should include instance variables, constructors, an area method, a perimeter method, a toString method, accessor and mutator methods, and user input. Your runner class should include 3 Rectangle objects. One default rectangle, one coded rectangle, and one user input...
Word to Digit Programming challenge description: Given a string representation of a set of numbers, print...
Word to Digit Programming challenge description: Given a string representation of a set of numbers, print the digit representation of the numbers. Input: Your program should read lines from standard input. Each line contains a list of word representations of numbers separated by a semicolon. There are up to 20 numbers in one line. The numbers are "zero" through "nine". Output: Print the sequence of digits. Test 1 Input zero;two;five;seven;eight;four Expected Test 1 output 025784 Test 2 Input three;seven;eight;nine;two Expected...
Challenge: Number Stats 2 Description: Extend the program you wrote for Number Stats to determine the...
Challenge: Number Stats 2 Description: Extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. Purpose: The purpose of this challenge is to provide experience working with numerical data in a file and generating summary information including the determination of median and mode. It also provides experience adding new functionality to an existing program. Requirements: Extend the program you wrote for Number Stats to determine the median and mode...
Description: To create a Visual Basic program that will obtain a sentence from the user, parse...
Description: To create a Visual Basic program that will obtain a sentence from the user, parse the sentence, and then display a sorted list of the words in the sentence with duplicate words removed. Tasks: Design a method (algorithm) to solve the above problem using pseudocode or a flowchart. Translate your algorithm into an appropriate VB program and test it using the following input sentence. "We are the world We are the children" Submit: Pseudocode version of algorithm/Flowchart version of...
Description: The purpose of the program is to create a Java ticket purchasing program that allows...
Description: The purpose of the program is to create a Java ticket purchasing program that allows for users to log in, purchase tickets, keep records of tickets purchased, and keep information about the user. Program Requirements: The following are the program requirements: Must be fully functioning including registration, log-in, view events, and purchase tickets Tickets should be purchased using “points”, no information should be provided via the user for payment method. Default each user to an allotted number of points...
write a program to calculate and print payslips write program that calculates and prints payslips. User...
write a program to calculate and print payslips write program that calculates and prints payslips. User inputs are the name of employee, numbers of hours worked and hourly rate c++ language
2) create a python program that uses a for loop and range to print out the...
2) create a python program that uses a for loop and range to print out the values 10 8 6 4 2 3) Create a python program that yses a for loop to print out ["bob","al","bert"]
Write a C++ program for the following problem: Calculate and print the area and volume of...
Write a C++ program for the following problem: Calculate and print the area and volume of a cone inside a While  loop that goes from 1 to 20 with a step of .5. (the step is 1/2 or Point 5, so you go 10, 10.5,11, 11.5) Note: Your loop variable will need to be a double data type Use two decimal places on all numbers that are double data type. This will be a table with 3 columns. Don't worry about...
Develop a basic portfolio business organization description. Develop and create an introduction of the business
Develop a basic portfolio business organization description. Develop and create an introduction of the business
Beginning Python Programming - Sorting: Write and test a Python program to print a set of...
Beginning Python Programming - Sorting: Write and test a Python program to print a set of real numbers in descending order. The program should also print out the median of the numbers input and how many numbers were input. The program should read in numbers until a negative number is read. The negative number serves as a sentinel or marker telling the program when to stop reading numbers. The program should then sort the numbers and print them out in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT