1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
// Declaring Variables
string studentName;
double exam_1, exam_2, exam_3, assign_1, assign_2;
double subtotal_Exam, subtotal_Assign;
double weighted_Exam, weighted_Assign;
double total;
char grade;
// Storing user's input for student name into string studentName
cout << "Please enter student name (First, Last): ";
getline(cin, studentName);
// Displaying message notifying user of the proper format for inputting scores
cout << "****************************NOTE****************************" << endl;
cout << "*** Be sure to include decimal point for scores. ***" << endl;
cout << "*** ***" << endl;
cout << "*** !!! All scores should range from 0.00 to 100.00 !!! ***" << endl;
cout << "*** ***" << endl;
cout << "*** For example : 80.50 or 73.97 ***" << endl;
cout << "****************************NOTE**************************** \n" << endl;
// Storing user's grade for exam 1
cout << "Please enter score for Exam 1 <EX. 0.00-100.00>: ";
cin >> exam_1;
if (exam_1 < 0 || exam_1 > 100.00) // If statement to see if exam 1 grade is within valid range: if so, moves to input for exam 2. if not then asks user to enter valid score.
{
cout << "Invalid exam score, stay within 0.00 - 100.00 range. Re-enter score for Exam 1: ";
cin >> exam_1;
if (exam_1 < 0 || exam_1 > 100.00) // Nested if statement to see if re-entered grade is valid, if not program notifies user and will end on next key press
{
cout << "Invalid input entered. PROGRAM WILL END. Restart program and follow directions " << endl;
cout << "carefully!" << endl;
//return 0;
}
}
// Storing user's grade for exam 2
cout << "Please enter score for Exam 2 <EX. 0.00-100.00>: ";
cin >> exam_2;
if (exam_2 < 0 || exam_2 > 100.00) // If statement to see if exam 2 grade is within valid range: if so, moves to input for exam 3. if not then asks user to enter valid score.
{
cout << "Invalid exam score, stay within 0.00 - 100.00 range. Re-enter score for Exam 2: ";
cin >> exam_2;
if (exam_2 < 0 || exam_2 > 100.00) // Nested if statement to see if re-entered grade is valid, if not program notifies user and will end on next key press
{
cout << "Invalid input entered. PROGRAM WILL END. Restart program and follow directions " << endl;
cout << "carefully!" << endl;
//return 0;
}
}
// Storing user's grade for exam 3
cout << "Please enter score for Exam 3 <EX. 0.00-100.00>: ";
cin >> exam_3;
if (exam_3 < 0 || exam_3 > 100.00) // If statement to see if exam 3 grade is within valid range: if so, moves to input for assignment 1. if not then asks user to enter valid score.
{
cout << "Invalid exam score, stay within 0.00 - 100.00 range. Re-enter score for Exam 3: ";
cin >> exam_3;
if (exam_3 < 0 || exam_3 > 100.00) // Nested if statement to see if re-entered grade is valid, if not program notifies user and will end on next key press
{
cout << "Invalid input entered. PROGRAM WILL END. Restart program and follow directions " << endl;
cout << "carefully!" << endl;
//return 0;
}
}
// Storing user's grade for assignment 1
cout << "Please enter score for Assignment 1 <EX. 0.00-100.00>: ";
cin >> assign_1;
if (assign_1 < 0 || assign_1 > 100.00) // If statement to see if assign_1 grade is within valid range: if so, moves to input for assignment 2. if not then asks user to enter valid score.
{
cout << "Invald assignment score, stay within 0 - 100.00 range. Re-enter score " << endl;
cout << "for Assignment 1: ";
cin >> assign_1;
if (assign_1 < 0 || assign_1 > 100.00) // Nested if statement to see if re-entered grade is valid, if not program notifies user and will end on next key press
{
cout << "Invalid input entered. PROGRAM WILL END. Restart program and follow directions " << endl;
cout << "carefully!" << endl;
//return 0;
}
}
// Storing user's grade for assignment 2
cout << "Please enter score for Assignment 2 <EX. 0.00-100.00>: ";
cin >> assign_2;
if (assign_2 < 0 || assign_2 > 100.00) // If statement to see if assign_2 grade is within valid range: if so, moves to student overview. if not then asks user to enter valid score.
{
cout << "Invald assignment score, stay within 0 - 100.00 range. Re-enter score " << endl;
cout << "for Assignment 2: ";
cin >> assign_2;
if (assign_2 < 0 || assign_2 > 100.00) // Nested if statement to see if re-entered grade is valid, if not program notifies user and will end on next key press
{
cout << "Invalid input entered. PROGRAM WILL END. Restart program and follow directions " << endl;
cout << "carefully! \n" << endl;
//return 0;
}
}
// Calculating subtotal of grades, weighted score of grades, and total score.
subtotal_Exam = exam_1 + exam_2 + exam_3;
subtotal_Assign = assign_1 + assign_2;
weighted_Exam = (subtotal_Exam * 50) / 300;
weighted_Assign = (subtotal_Assign * 50) / 200;
total = weighted_Exam + weighted_Assign;
cout << "---------------------STUDENT OVERVIEW---------------------" << endl;
cout << " Student name: " << student_Name << endl;
cout << " Exams Assignments \n" << endl;
cout << setprecision(2) << fixed;
cout << "1. " << setw(50) << exam_1 << setw(16) << assign_1 << endl;
cout << "2. " << setw(50) << exam_2 << setw(16) << assign_2 << endl;
cout << "3. " << setw(50) << exam_3 << "\n" << endl;
cout << "Subtotal " << setw(44) << subtotal_Exam << setw(16) << subtotal_Assign << endl;
cout << "Weighted Score " << setw(38) << weighted_Exam << setw(16) << weighted_Assign << "\n" << endl;
cout << "Total " << setw(47) << total << endl;
return 0;
}
|