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
|
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <ctime>
using namespace std;
void print_menu();
void print_all();
void input_new_student(string student_name[42], int r_identifier[42], double gpa_entry[42], int index, int year_entry[42]);
int get_selection(int menu_Selection);
double get_gpa();
int get_year();
void print_by_year();
string get_name();
void print_statistics();
int main() //Handles the if statements concerning the menu of the program
{
int r_identifier[42]; //Variable Declaration
int year_entry[42];
double gpa_entry[42];
string student_name[42];
int index;
int menuchoice; //Variable Declaration
do
{
print_menu(); //Calls function to print menu
get_selection(menuchoice); //Calls function to get the menu selection
if (menuchoice == 1) //Calls the function to input a new user
{
input_new_student(student_name, r_identifier, gpa_entry, index, year_entry);
}
else if (menuchoice == 2) //Prints all
{
print_all ();
}
else if (menuchoice == 3) //Prints statistics about all students in a particular year
{
int year_view;
cout << "What year would you like to display?";
cin >> year_view;
while (year_view < 1972 || year_view > 2016) //Validates input
{
cout << "Error: Invalid input, please try again: ";
cin >> year_view;
}
print_by_year();
}
else if (menuchoice == 4) //Prints statistics about all entered users
{
print_statistics();
}
else if (menuchoice == 5) //Quits the program
{
cout << "Have a good summer! ";
cout << endl;
}
} while (menuchoice != 5);
return 0;
}
void print_menu() //Prints Registrar menu
{
cout << "RCNJ Registrar Menu: " << endl;
cout << "\n[1] Add a student" << endl;
cout << "[2] Display all students" << endl;
cout << "[3] Display by year" << endl;
cout << "[4] Display statistics" << endl;
cout << "[5] Quit" << endl;
}
void input_new_student(string student_name[42], int r_identifier[42], double gpa_entry[42], int index, int year_entry[42])
//Calls all necessary functions to input a new student
{
get_name();
get_year();
get_gpa();
student_name[index] = get_name(); //Sets student name entry to index allocation
year_entry[index] = get_year(); //Sets year entry to index allocation
gpa_entry[index] = get_gpa(); //Sets gpa entry to index allocation
}
int get_selection(int menu_Selection) //Gets the menu selection
{
cout << "\nSelection: ";
cin >> menu_Selection;
while (menu_Selection < 1 || menu_Selection > 5) //Validates input
{
cout << "Error: Invalid input, please try again: ";
cin >> menu_Selection;
}
return menu_Selection; //Returns the user inputted menu selection
}
double get_gpa() //Function to get the GPA
{
double gpa_entry;
cout << "Please enter the GPA: ";
cin >> gpa_entry;
while (gpa_entry < 0.0 || gpa_entry > 4.0) //Validates input
{
cout << "Error: Invalid input, please try again: ";
cin >> gpa_entry;
}
return gpa_entry; //Returns the gpa entry to input new student
}
int get_year() //Function to get year
{
int year_entry_date;
cout << "Please enter the year: ";
cin >> year_entry_date;
while (year_entry_date < 1972 || year_entry_date > 2016) //Validates input
{
cout << "Error: Invalid input, please try again: ";
cin >> year_entry_date;
}
return year_entry_date; //Returns year entry to input new student
}
string get_name() //Function to get student name
{
string student_name_entry;
cout << "Please enter the student's name: ";
cin >> student_name_entry;
return student_name_entry; //Returns student name to input new student function
}
void print_by_year() //Function to print student information by year attended
{
}
void print_statistics() //Function which prints all statistics about students
{
}
void print_all()
{
}
|