User:Smiller382/sandbox

'''/* Name: Sarah Date: 10.29.2018 Description: Student ID Program, in C++ code


 * 1) include
 * 2) include
 * 3) include
 * 4) include

using namespace std;

//structure for student struct schoolStudent {	string studentName; double grade; double money; int studentID; };

//prototypes double setGrade(int count); double setLunchMoney(int count); int setStudentID(int count);

//main int main {	//variables schoolStudent students[5]; string name = ""; double studentGrade = 0.0; double studentMoney = 0.0; int studentID = 0; int choice = 0; int hold = 0; double average = 0.0; int count = 0; string answer = "";

cout << showpoint << fixed << setprecision(2); //set output to 2 decimals do {		cout << "Welcome to Sarah's PowerSchool!\n" << endl;

//enter info cout << "Enter information for student " << count + 1 << endl;

cout << "Please enter the name: "; cin >> name; students[count].studentName = name; //assign the name cout << "The name is: " << students[count].studentName << endl;

students[count].grade = setGrade(count); //assign the grade cout << "The grade is: " << students[count].grade << "%" << endl;

students[count].money = setLunchMoney(count); //assign the lunch money cout << "The balance is: $" << students[count].money << endl;

students[count].studentID = setStudentID(count); //assign the ID		cout << "The ID is: " << students[count].studentID << "\n" << endl; count++; //increment count } while (count < 5); //5 times

//look up information cout << "Would you like to look up any information? (Enter \"y\" for yes or \"n\" for no)" << endl; cin >> answer; while (answer != "y" && answer != "Y" && answer != "n" && answer != "N") //invalid answer {		cin.clear; //clear bad input flag cin.ignore(numeric_limits ::max, '\n'); //discard input cout << "Invalid input; please re-enter.\n"; cin >> answer; }	while (answer == "y" || answer == "Y") {		cout << "Enter the ID of the person you want to see." << endl; while (!(cin >> choice) || choice < 1 || choice > 5) {			cin.clear; //clear bad input flag cin.ignore(numeric_limits ::max, '\n'); //discard input cout << "Invalid student ID; please re-enter.\n"; }		cout << "You chose to view student " << choice << "'s information." << endl; cout << "Their name is: " << students[choice - 1].studentName << endl; cout << students[choice - 1].studentName << "'s grade is: " << students[choice - 1].grade << "%" << endl; cout << students[choice - 1].studentName << "'s lunch balance is: $" << students[choice - 1].money << endl;

cout << "\nWould you like to look up more information? (Enter \"y\" for yes or \"n\" for no)" << endl; cin >> answer; while (answer != "y" && answer != "Y" && answer != "n" && answer != "N") //invalid answer {			cin.clear; //clear bad input flag cin.ignore(numeric_limits ::max, '\n'); //discard input cout << "Invalid input; please re-enter.\n"; cin >> answer; }	}

cout << "\nHave a good day!" << endl;

cin >> hold; return 0; }

//functions //set grade for the student double setGrade(int count) {	int grade1 = 0; int grade2 = 0; int grade3 = 0; cout << "What is the last grade you got on your math assignment?" << endl; while (!(cin >> grade1) || grade1 > 100 || grade1 < 0) //invalid answer {		cin.clear; //clear bad input flag cin.ignore(numeric_limits ::max, '\n'); //discard input cout << "Invalid grade; please re-enter.\n"; }

cout << "What is the last grade you got on your math quiz?" << endl; while (!(cin >> grade2) || grade2 > 100 || grade2 < 0) //invalid answer {		cin.clear; //clear bad input flag cin.ignore(numeric_limits ::max, '\n'); //discard input cout << "Invalid grade; please re-enter.\n"; }

cout << "What is the last grade you got on your math test?" << endl; while (!(cin >> grade3) || grade3 > 100 || grade3 < 0) //invalid answer {		cin.clear; //clear bad input flag cin.ignore(numeric_limits ::max, '\n'); //discard input cout << "Invalid grade; please re-enter.\n"; }

return (grade1 + grade2 + grade3) / 3; //returns the average }

//set lunch money for the student double setLunchMoney(int count) {	double studentMoney = 0.0; int choice = 0; cout << "What is your lunch money balance?" << endl; while (!(cin >> studentMoney)) //invalid answer {		cin.clear; //clear bad input flag cin.ignore(numeric_limits ::max, '\n'); //discard input cout << "Invalid balance; please re-enter.\n"; }	return studentMoney; }

//set ID for the student int setStudentID(int count) {	//adds 1 to count since count in the while loop starts at 0 return count + 1; }'''