Write a progrma analysis by looking at coded above (language c++)
ID: 3544897 • Letter: W
Question
#include <iostream> #include <iomanip> using namespace std; void displayGrade(int); void outstanding (int); void satisfactory (int); void unsatisfactory (int); int main() { const int SENTINEL = -99; int score, sum = 0, count = 0, outstanding = 0, satisfactory = 0, unsatisfactory =0; double average; cout <<"Assignment 16 by " << endl << endl; cout << "Enter scores one at a time as requested." << endl; cout << "When done, enter " << SENTINEL << " to finish entering scores." << endl; cout << "Enter the first score: "; cin >> score; while (score != SENTINEL) { sum += score; count++; displayGrade(score); cout << endl<< "Enter the next score: "; cin >> score; if (score >= 90) { outstanding = score >= 90; outstanding++; } else if (score >=60){ satisfactory = score >= 60; satisfactory++; } else { unsatisfactory =score <=59; unsatisfactory++; } } cout << endl << endl; cout << "Number of scores processed is " << count << endl; cout << "Sum of exam scores is " << sum << endl; cout << "The number of Outstanding scores is: " << outstanding << endl; cout << "The number of Satisfactory scores is: " << satisfactory << endl; cout << "The number of Unsatisfactory scores is: " << unsatisfactory << endl; if (count > 0) { average = sum / count; cout << "Average score is " << average << endl; } return 0; } void displayGrade(int score) { if (score >= 90) cout << "Grade is A" << endl; else if (score >= 80) cout << "Grade is B" << endl; else if (score >= 70) cout << "Grade is C" << endl; else if (score >= 60) cout << "Grade is D" << endl; else cout << "Grade is F" << endl; }
Program Analysis:
Program Inputs:
Program Outputs:
Program Algorithm:
Program Test Plan:
Program Test Results:
Functions
(Repeat this section for each of your functions). Provide the function prototype here.
Function Analysis:
Function Preconditions and Post Conditions:
Function Inputs and Outputs:
Function formulas:
Function Algorithm:
Explanation / Answer
Program Inputs : Program requires user to enter the series of scores (integer numbers), and requires user to enter -99 to stop entering the scores.
Program Outputs: Program outputs the average of all the scores that a user enters and displays the values of outstanding,satisfactory as 2 if any of the scores crosses 90,60 respectiively otherwise displays 0.
If any of the scores is less than 60 then the system displays a value of 2 otherwise it displays 0.
The program also display the grade for each score.
It Displays Grade A if the scores fall between 90 and 100.
It Displays Grade B if the scores fall between 80 and 89.
It Displays Grade C if the scores fall between 70 and 79.
It Displays Grade D if the scores fall between 60 and 69.
It displays Grade F if the scores are less than 60.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.