When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
4 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
// Lab 4 - GPA Calculator
// Constants
const double DEANS_LIST = 3.79;
const double COURSE_NUM = 3;
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
// Local Variables for Data Storage
string course1, course2, course3;
double credit1, credit2, credit3;
char grade1, grade2, grade3;
double gpa;
string str;
// Display Welcome Message
cout << "~~ Welcome to the Grade Point Average Calculator Application! ~~\n";
cout << " This program will calculate the Grade Point Average for three courses.\n";
// Format the Output to 2 Decimals
cout << fixed << setprecision(2);
// Prompt & Get the 3 Course Name, Credit, & Grade
cout << "Enter the name of the first course: ";
getline(cin, course1);
cout << "Enter the number of credits earned in " << course1 << endl;
cin >> credit1;
cout << "Enter the grade earned in" << course1 << endl;
cin >> grade1;
cout << "Enter the name of the second course: \n";
getline(cin, course2);
cout << "Enter the number of credits earned in " << course2 << endl;
cin >> credit2;
cout << "Enter the grade earned in " << course2 << endl;
cin >> grade2;
cout << "Enter the name of the third course: \n";
getline(cin, course3);
cout << "Enter the number of credits earned in " << course3 << endl;
cin >> credit3;
cout << "Enter the grade earned in " << course3 << endl;
cin >> grade3;
// Calculate the GPA
gpa = ((credit1 * grade1) + (credit2 * grade2) + (credit3 * grade3)) / (credit1 + credit2 + credit3);
// Display Course Name, Credit, & Grade
cout << left << endl;
cout << setw(10) << course1 << setw(10) << course2 << setw(10) << course3 << endl;
// Deans List
if (gpa >= 3.79)
cout << "You made the Dean's List! \n";
else
cout << "Oh well, keep trying. \n";
return 0;
}```
@night vector
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.
!solved