Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Christian Ballard
- //COSC 1330 - 003
- //This program should calculate and dislplay a student's letter grade.
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- char letterGrades[5] = { 'A', 'B', 'C', 'D','F' };//Inputs!!!
- int letterGradeNumbers[5] = { 90, 80, 70, 60, 0 };
- double possiblePoints = 0.0;
- double pointsRecieved = 0.0;
- double percentGrade = 0.0;
- char updateRead = ' ';
- cout << fixed << setprecision(1);//I decided to show the percent grade and didn't want the decimal to run on.
- do//The loop that loops the entire program.
- {
- system("cls");//Clearing the screen.
- cout << "Please enter how many points are possible to recieve." << endl;//Getting some inputs.
- cin >> possiblePoints;
- cout << "How many points did you recieve?" << endl;
- cin >> pointsRecieved;
- percentGrade = (pointsRecieved / possiblePoints) * 100;//Our calculations.
- for (int counter = 0; counter < 5; counter++)//Our second loop that determines the letter grade.
- {
- if (percentGrade >= letterGradeNumbers[counter])//Figuring out what letter to use.
- {
- cout << "Your percent grade is " << percentGrade << endl;//Displays.
- cout << "Your letter grade is " << letterGrades[counter] << endl;
- break;//Breaking us out of the loop.
- }
- }
- updateRead = toupper(updateRead);//Keeping letters uppercase for the update read for the loop.
- cout << "Would you like to calculate another grade? (Y/N)" << endl;//Update read.
- cin >> updateRead;
- } while (updateRead == 'Y'); //End of the loop.
- system("cls");
- if (updateRead = 'N')
- cout << "Goodbye!" << endl;//Exiting.
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment