Cs160 - 0102 project - examination statistics assignment


Examination Statistics Assignment

Learning Outcomes

  • Recognize and apply the software development phases
  • Utilize Java syntax in fundamental programming algorithms
  • Recognize and apply the various input and output devices in programming
  • Recognize and apply the various control structures
  • Design and implement user defined methods

Objectives - In completing this project you will gain experience with the following Java features:

  • the Scanner class
  • formatting
  • selection structures
  • iteration structures
  • file input-output

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

  • 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
  • an undetermined number of exam scores stored on an external input file; each number is an integer between 0 and 100
  • 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. Decimals must be rounded to two digits after the point. Use printf or String.format to get the output properly formatted.

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 keyboard 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 that is, the loop continues at the next iteration. Wrong input does not update any of the counter variables, neither the sum, maxScore and minScore variables. Note that every correct input must be fully processed at the reading; only the data currently read from the file can be stored internally by the code.

Compute the average

Re-instantiate the file reader Scanner object, you need a new Scanner since you have to read the file again

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

Compute psd

Compose the output message, use the String.format( ) method

Display the message on the console

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

Implementation Requirements and Hints

  • 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

(i) declare a File object

(ii) run a while loop in which solicit, read and save a candidate for the file name

(iii) instantiate the File object to the file name

(iv) check if the file exists, if it does not, continue the loop, otherwise stop the loop

First file reading:

  • In the while loop that reads the scores from the file

(i) Save the currently read input in nextScore

(ii) You may assume that the data read is numeric value, but the input must validated to the required bounds; wrong input is ignored, the loop turns to the next iteration

(iii) Update the total counter

(iv) Check if nextScore is greater than maxScore, if so update maxScore with nextScore

(v) Repeat the checking for minScore

(vi) Apply a nested if else if structure to determine the grade group relevant for nextScore and update the group counter; as an alternate option you are allowed to use a properly crafted switch statement rather than if-else statements

(vii) Add nextScore to sum

  • After the loop, compute average by applying the average formula; care for the integer division, average must be exact

Second file reading:

  • Note that the score data are not stored internally by the program, and to compute the standard deviation (psd) the average must have been determined. Therefore average and psd cannot be simultaneously calculated in one file reading process. In order to compute the value of psd, the file containing the data (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.

 

Solution Preview :

Prepared by a verified Expert
Computer Engineering: Cs160 - 0102 project - examination statistics assignment
Reference No:- TGS02765658

Now Priced at $40 (50% Discount)

Recommended (96%)

Rated (4.8/5)