Question: #include #include Student.h using namespace std; Student::Student(string n, double gpa, string m) { this->name = n; this->gradPointAvg = gpa; this->major = m; } void Student::display()
#include #include "Student.h" using namespace std; Student::Student(string n, double gpa, string m) {
this->name = n; this->gradPointAvg = gpa; this->major = m;
}
void Student::display() {
cout << "Name : " << name << endl; cout << "GPA: " << gradPointAvg << endl; cout << "Major: " << major << endl; }
int main() {
Student students[10];
// Get all the student details int n = 50; for (int i = 0; i< n; i++) {
cout << " Enter student " << (i + 1) << " details : " << endl;
cout << "Name : "; string name; cin >> name;
cout << "GPA : "; double gpa; cin >> gpa;
cout << "Major : "; string major; cin >> major;
// create a new student with the user data
Student s(name, gpa, major);
// insert the student to the list of students
students[i] = s;
}
cout << " The students details are : ";
for (int i = 0; i
cout << " Student " << (i + 1) << " details : " << endl;
students[i].display();
}
return 0;
}
i would like some help i want this code to display an error message for the user entries. such as if the user enters 5.0 for the gpa it would error him and promt him to enter something less than 4.0. nowi know it would be done with an if statment but how and where would i put it mind u i need it done for VS with just c++ coding
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
