hello all i am having a problem setting validation. i have written this code and it works. when i try and put in validation with if statements it keeps crashing the program. i have no idea where to go from here. here is what i am trying to do:
Modify my StudentGrade class that the "set" methods perform data validation. A student ID should be in the range of 10000-50000, and a grade should be in the range 0 - 100. Use a single "if" statement (using the && operator) in each "set" method.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <string>
using std::string;
using std::getline;
Code:class StudentGrade { public: //function that sets the student ID void setStudentID( string number ) { studentID = number; //store the course name in the object } //function that gets the student ID string getStudentID() { return studentID; //returns the objects Student ID } void setTestScore( string score ) { testScore = score; } string getTestScore() { return testScore; } void displayMessage() { cout << "Student " << getStudentID() << " has a score of " << getTestScore() << endl; } private: string studentID; string testScore; }; int main() { string studentIDnumber; string studentTestscore; StudentGrade myStudentID; if ( studentIDnumber < 10000 && >50000 ) cout<< "The number must be between 10000 - 50000. "; else cout << "Student ID is: " <<myStudentID.getStudentID() << endl; cout << "\nPlease enter the Student ID number:" << endl; getline( cin, studentIDnumber ); myStudentID.setStudentID( studentIDnumber ); cout << endl; cout << "Student test score is: " <<myStudentID.getTestScore() << endl; cout << "\nPlease enter the Student Test Score:" << endl; getline( cin, studentTestscore ); myStudentID.setTestScore( studentTestscore ); cout << endl; myStudentID.displayMessage(); return 0; }