C++ beginnersProgram

Hi I'm a student of computer science and I'm doing c++ programming class and I'm really stuck in a homework about making a program that needs to prompt the user for the number of credits they have completed and calculate their classification.

here is what I have done so far but the big problem for me is that the Professor is asking me to:

Do not accept negative values, letters, or characters such as !, ?.#,$, etc. Test your code for the following input:
- a negative value: enter "-1" for number of credits
- a letter: enter "a" for number of credits
- other characters: enter " !" for number of credits

and the platform where he is evaluating the task does not accept my ways.

#include <iostream>
#include <string>

using namespace std;

int main()
{
// declare variables
int numCredits; //to hold number of credits
string studentClassification //to hold student Class

// prompt the user for number of credits
cout << "How many credits did you complete: ";
cin >> numCredits;

// read user input and store into numCredits

// safe programming practice

// display contents of num credits and student classification

return 0;
}



Please somebody help me out with this Thankssssss a lot
Have you covered loops? You'll need to repeat asking for input until you get a valid input.
Topic archived. No new replies allowed.