# CS 2400 Lab # 4 Grade Frequencies solved

\$35.00

## Description

5/5 - (1 vote)

Topics Covered:
File streams, loops, if statements, value-returning functions, void functions.
Step 1: Set up a separate directory for this lab.
First create a subdirectory called lab4.
a. Type cd 2400/Labs
b. Type mkdir lab4
c. Type cd lab4
Step 2: Program
Write a C++ program that repeatedly inputs students’ scores and determines the letter grades. The
scores should be stored in a file called “scores.txt”. For each score, output the score along
with its letter grade. Your program should count the number of A’s, B’s, etc. Use five counters
(aCount, bCount, etc). See main program below.
The letter grade is determined based on the following scale:
>= 90 (A), >= 80 (B), >= 70(C), >= 60(D), >= 0(F).
Output all frequencies.
Your program must, at least, include the following functions:
• A function (getGrade) that takes a score as a parameter and returns a letter grade.
• A void function to print the score and the grade.
• A void function to print the frequencies.
void printFrequencies(int aCount, int bCount,
int cCount, int dCount, int fCount);
Main Program:
int main() {
double score;
int aCount = 0, bCount = 0, cCount = 0, dCount = 0, fCount = 0;
//open the file for input
//get the first score
while(not end of file) {
//output the score and the grade
//determine which counter is updated
//get the next score
}
//output the frequencies
}
CS2400 Lab # 4 June 4, 2019
Sample Input File:
44 55 66 77 88 99 50
60 70 80 90 78.5 99.5
Sample output: