Skip to content

Instantly share code, notes, and snippets.

@Newtochr

Newtochr/P4 Secret

Created April 16, 2020 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Newtochr/2e0aa3246c895d4fa3d18ccb9300c4e5 to your computer and use it in GitHub Desktop.
Save Newtochr/2e0aa3246c895d4fa3d18ccb9300c4e5 to your computer and use it in GitHub Desktop.
Code Review P4
// #include "stdafx.h"
#include <iostream> // I/O operations
#include <iomanip> // Formatting functions
#include <cstdlib> // General use library functions
#include <string> // Defines dynamic string stuff
using namespace std;
// Prototypes --------------------------------------------------------------------
void splash_scrn(void);
void menu_scrn(string last, string first, string csid, string grade1, string grade2, string grade3, string grade4, string grade5, string grade6);
void input_scrn(string last, string first, string csid, string grade1, string grade2, string grade3, string grade4, string grade5, string grade6);
void output_scrn(string last, string first, string csid, string grade1, string grade2, string grade3, string grade4, string grade5, string grade6);
void transition(void);
void error_scrn(void);
// End of Prototypes -------------------------------------------------------------
int main()
{
// Variable and object creation ----------------------------------------------
string csid = "XXXX";
string first = "XXXX";
string last = "XXXX";
string grade1 = "XXXX";
string grade2 = "XXXX";
string grade3 = "XXXX";
string grade4 = "XXXX";
string grade5 = "XXXX";
string grade6 = "XXXX";
char letter_grade = 'A';
double grade1_num = atof(grade1.c_str());
double grade2_num = atof(grade2.c_str());
double grade3_num = atof(grade3.c_str());
double grade4_num = atof(grade4.c_str());
double grade5_num = atof(grade5.c_str());
double grade6_num = atof(grade6.c_str());
int ctr = 0; // controls loops
// Transition screen variable
string resp = "XXXX";
string ans = "XXXX"; // New for this program
// End of variable declarations ----------------------------------------------
// Beginning of the Splash Screen --------------------------------------------
splash_scrn();
// End of the Splash Screen --------------------------------------------------
// Transition to next screen
transition();
// End of transition
// Start of Menu Screen ------------------------------------------------------
menu_scrn(last, first, csid, grade1, grade2, grade3, grade4, grade5, grade6);
// menu_scrn()
// End of Menu screen --------------------------------------------------------
}// End of int main() --------------------------------------------------------
// Function Definitions ---------------------------------------------------------
void splash_scrn(void)
{
system("cls");
cout << R"(
_______ _______ _______ ______ _______ _______
| | | | |______ | ____ | |______
| | | |_____ ______| |_____| | ______|
_
-=\`\
|\ ____\_\__
-=\c`""""""" "`)
`~~~~~/ /~~`---
-==/ /
'-'
_ _
( ` )_
( ) `) _ _
(_ (_ . _) _) ( ` )_
( ) ( _) _)
( ` ) . )
(_, _( ,_)_)
Random College
STUDENT GRADE TRACKING SYSTEM
Programmed By: Anon
Rev 1.0 - 2/16/2020
)" << endl;
} // End of void splash_scrn(void)
void transition(void)
{
string resp = "XXX";
cout << " Press <ENTER> to Continue";
getline(cin, resp);
system("cls");
} // End of void transition(void)
void menu_scrn(string last, string first, string csid, string grade1, string grade2, string grade3, string grade4, string grade5, string grade6)
{
string ans = "XXXX";
do
{
cout << endl << endl;
cout << " Random College" << endl;
cout << " STUDENT GRADE TRACKING SYSTEM" << endl;
cout << " ( Main Menu )" << endl;
cout << endl << endl;
cout << " <I>nput Student Information";
cout << " <O>utput Average Grades";
cout << " <E>xit" << endl;
cout << endl;
cout << endl << endl << endl;
cout << " Enter I, O, or E: ";
getline(cin, ans);
system("cls");
//-------- End of Menu options ---------------------------
switch (ans.at(0)) // Beginning of the switch block
{
case 'I':
case 'i':
// Start of Input Screen -----------------------------------------------------
cout << endl;
cout << " Random" << endl;
cout << " STUDENT GRADE TRACKING SYSTEM" << endl;
cout << " ( Input Screen )" << endl;
cout << endl;
cout << " ----------------------------------------------------------------------------- " << endl;
cout << endl;
cout << " Please press <ENTER> after inputting data";
cout << endl << endl;
cout << " Last Name: "; getline(cin, last);
cout << " First Name: "; getline(cin, first);
cout << endl;
cout << " Student ID Number (10-Digit): "; getline(cin, csid);
cout << endl;
cout << " ----------------------------------------------------------------------------- " << endl;
cout << endl;
cout << " Grade 1: "; getline(cin, grade1);
cout << " Grade 2: "; getline(cin, grade2);
cout << " Grade 3: "; getline(cin, grade3);
cout << " Grade 4: "; getline(cin, grade4);
cout << " Grade 5: "; getline(cin, grade5);
cout << " Grade 6: "; getline(cin, grade6);
cout << endl;
cout << endl;
// End of the Input Screen ---------------------------------------------------
// Transition to next screen
transition();
// End of transition
break;
case 'O':
case 'o':
// Start of Output Screen ----------------------------------------------------
output_scrn(last, first, csid, grade1, grade2, grade3, grade4, grade5, grade6);
// End of the Output Screen --------------------------------------------------
// Transition to next screen
transition();
// End of transition
break;
case 'E':
case 'e':
break;
default:
error_scrn();
transition();
} // End of switch(resp.at(0))
} while (toupper(ans.at(0)) != 'E');
// End menu processing
}// End of void menu()
void output_scrn(string last, string first, string csidr, string grade1, string grade2, string grade3, string grade4, string grade5, string grade6)
{
// Calculations
double Average = (grade1_num + grade2_num + grade3_num + grade4_num + grade5_num + grade6_num) / 6.0;
{
if (Average > 100)
letter_grade = '+';
else
if (Average >= 90)
letter_grade = 'A';
else
if (Average >= 80)
letter_grade = 'B';
else
if (Average >= 70)
letter_grade = 'C';
else
if (Average >= 60)
letter_grade = 'D';
else
if (Average >= 50)
letter_grade = 'E';
else
if (Average >= 0)
letter_grade = 'F';
else
letter_grade = '-';
}
int ctr = 0;
cout << endl;
cout << " Random College" << endl;
cout << " STUDENT GRADE TRACKING SYSTEM" << endl;
cout << " ( Output Screen )" << endl;
cout << R"(
90 - 100 -> A
80 - 90 -> B
70 - 80 -> C
60 - 70 -> D
50 - 60 -> E
less than 50 -> F
----------------------------------
)";
cout << " Student Name (Last, First): " << last;
cout << " " << first << endl;
cout << " CSID: " << csid << endl;
cout << endl;
cout << " Grade 1: " << grade1 << endl;
cout << " Grade 2: " << grade2 << endl;
cout << " Grade 3: " << grade3 << endl;
cout << " Grade 4: " << grade4 << endl;
cout << " Grade 5: " << grade5 << endl;
cout << " Grade 6: " << grade6 << endl;
cout << endl;
cout << " Total Grade Average: " << Average;
cout << " Letter Grade: " << letterGrade << endl;
if (Average > 100) {
letterGrade = '+';
cout << " Error: Grade cannot be more than 100";
}
if (Average < 0) {
letterGrade = '-';
cout << " Error: Grade cannot be less than 0";
}
cout << endl;
}// End of void output( )
void error_scrn(void)
{
cout << endl;
cout << " Random College" << endl;
cout << " STUDENT GRADE TRACKING SYSTEM" << endl;
cout << " ( Error Screen )" << endl;
cout << endl << endl;
cout << "----------------------------------------------------------------------------";
cout << endl;
cout << " Error: Enter I, O, or E!" << endl;
}// End of void error_scrn(void)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment