Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <iomanip>
- using namespace std;
- int main()
- {
- string a;
- string b;
- char ch;
- int grade; // I put this here because my the switch in the parathensis is called grade and unless i declare it as something it won't compile properly and run.
- double c;
- double d;
- double e;
- int Average;
- int sum;
- cout << "Enter the first name " << endl;
- cin >> a;
- cout << "Enter the last name" << endl;
- cin >> b;
- cout << "Enter the three test scores" << endl;
- cin >> c >> d >> e;
- sum = c+d+e;
- Average = sum/3;
- grade = Average;
- cout << setfill('-');
- cout << "First" << setw(9);
- cout << "Last" << setw(25);
- cout << "Test 1" << setw(8);
- cout << "Test 2" << setw(8);
- cout << "Test3" << setw(10);
- cout << "Average" << setw(8);
- cout << "Grade" << endl;
- cout << a << setw(11);
- cout << b << setw(24);
- cout << c << setw(8);
- cout << d << setw(8);
- cout << e << setw(10);
- cout << Average << setw(8);
- switch (grade)
- {
- case 0:
- case 1:
- case 2:
- case 3:
- cout << "F";
- break;
- case 4:
- cout << "D";
- break;
- case 5:
- cout << "C";
- break;
- case 6:
- cout << "C+";
- break;
- case 7:
- case 8:
- cout << "B";
- break;
- case 9:
- case 10:
- cout << "A";
- break;
- default:
- cout << "Invalid Entry";
- }
- cout << endl << endl;
- ofstream myfile;
- myfile.open("example.txt");
- myfile << a << b << c << d << e << grade << '\n';
- myfile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement