Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement Processing large amount of data to obtain statistical information is a frequent computer application in many areas. The most frequently calculated parameters are

Problem Statement

Processing large amount of data to obtain statistical information is a frequent computer application in many areas. The most frequently calculated parameters are the average, the median, and the population standard deviation.

In this project, you implement a program that

  • reads examination scores from a file
  • determines the total number of scores in the file
  • calculates the average score
  • determines the maximum score and the minimum score
  • calculates the population standard deviation
  • determines the number of examination in each of the letter grade groups A, B, C, D, F
  • makes the output message displayed on the console, and writes the output to a file, as well

Analysis and Requirements

Input

  1. named constants to store the lower score limits for the letter grade groups, these are 85, 75, 65, 55 in the order of grades A, B, C, D
  2. an undetermined number of exam scores stored on an external input file; each number is an integer between 0 and 100
  3. the name of the input file to be solicited from the user on the console

Output

The output will contain the following data:

  • The total number of examinations
  • The average score
  • The population standard deviation of the scores
  • The minimum score
  • The maximum score
  • The number as well as the percentage of scores in each letter grade group

A template to be followed in displaying the output is shown below (Figure 1). Your actual output may have other numerical values.

Exam Statistics

Total: 59

Average score: 69.24

Population standard deviation of the scores: 16.36

# of A, 85-100: 9 15.25%

# of B, 75--84: 16 27.12%

# of C, 65--74: 18 30.51%

# of D, 55--64: 6 10.17%

# of F, 00--54: 10 16.95%

Minimum score: 16

Maximum score: 96

Figure 1

Note that all decimal numbers must be rounded to two decimals, and all the score listing lines must contain 10 numbers (except may be the last one).

Formulas needed

Average: The average score is the sum of the individual scores divided by the total number of scores. Avoid integer division. If N is the total number of scores and x1, x2, , xN are the score values then

average = (x1+x2++xN)/N

Population standard deviation: The difference of each score and the average squared, added, divided by N, and take the square root of the result.

psd * psd = ((average x1)2+(average x2)2++(average - xN)2)/N

Design

For this project you shall define a classes named ExamStatistics.

Add four static named constant fields to store the lower limits of the grade groups, see in Input above.

These variable are declared in the class but outside of the main method.

Within the main method, create commented places for codes responsible for various tasks.

//Declare variables

You will need

  • six integer variables for counting; one counter variable is used to count the total number of scores on the file, and one additional variable is needed to count the scores for each of the grades A, B, C, D and F
  • three integer variables minScore, maxScore, nextScore; minScore and maxScore are used to store the lowest and highest score values, nextScore stores score currently read from the file
  • three double variables to store sum, average and psd
  • two String variables to store the output message and the file name

// Declare and instantiate a Scanner object for console reading

//Declare and instantiate a File object to the file name solicited and received from the console

//Check if the file exists and repeat file name solicitation until the name accepted (a loop will be used)

//Declare and instantiate another Scanner object reader to read data from the file

//Run a while loop to read, count and sum the scores (running total); the loop must also have logic to determine maxScore, minScore, and must count the occurrences of scores in the grade groups; input values are checked, wrong input are not counted and they are ignored in the processing (the loop continues at the next iteration if wrong input was found). Wrong input does not update any of the counter variables, neither the sum, maxScore and minScore variables.

//Compute the average

//Re-instantiate the file reader Scanner object

//Run a for loop that makes the summation for psd, see the formula for psd

//Compute psd

// Compose the output message

//Display the message on the console

// Instantiate a PrintWriter object and write the output to a file named ExamStatFile

Implementation Requirements and Hints

  • You must have a comment block preceding the header of each of your classes that has the following content: /* * * CS 16000-01 02/03/04, Spring Semester 2020 * Project 2: Examination Statistics * * Description. * */
  • Having the name of the input file read from the console, the name shall be saved in a variable, say inputFileName
  • To validate the file name
  1. declare a File object
  2. run a while loop in which solicit, read and save a candidate for the file name
  3. instantiate the File object to the file name
  4. check if the file exists, if it does not, continue the loop, otherwise stop the loop
  • In the while loop that reads the scores from the file
  1. Save the currently read input in nextScore
  2. Validate the input; wrong input not processed, the loop turns to the next iteration
  3. Update the total counter
  4. Check if nextScore is greater than maxScore, if so update maxScore with nextScore
  5. Repeat the checking for minScore
  6. Apply a nested if else if structure to determine the grade group relevant for nextScore and update the group counter
  7. Add nextScore to sum
  • After the loop, compute average by applying the average formula; care for the integer division, average must be exact
  • Note that the score data are not stored internally by the program, and to compute the standard deviation (psd) the average is already must be known. Therefore, average and psd cannot be simultaneously determined in one file reading process. In order to compute the value of psd, the file inputFileName must be read once more by a new Scanner
  • As for the second reading of the file, a for loop is applicable since the total number of admissible items in the file is known. Input evaluation is still necessary to discard the wrong inputs. You may decide if you want to use a while loop for the second reading, or you want to apply a for loop.
  • Having the second loop completed and psd determined, the output message containing the obtained results must be built; decimal numbers in the output must be formatted and rounded to two digits after the point
  • Declare and instantiate a PrintWriter object to write the output to a file named ScoreStatistics.txt
  • Print the output to console and write output to file as required

Start your work on this project without delay.

Testing

Run your code with the supplied text file to_test.txt and use the data of Figure 2 for correctness. If the program is working correct, run the program with the input file exam_scores.txt as well.

Exam Statistics

Total: 11

Average score: 69.91

Population standard deviation of the scores: 17.22

# of A, 85-100: 2 18.18%

# of B, 75--84: 2 18.18%

# of C, 65--74: 2 18.18%

# of D, 55--64: 3 27.27%

# of F, 00--54: 2 18.18%

Minimum score: 44

Maximum score: 100

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions