I'm new to C++ and trying to create a program in which the user enters an integer value for number of items wanted. While the program runs with int values, it doesn't work when values like '2.2, 1.34a, b5' are entered.
Here's my program so far:
int main(){
int nuts, bolts, screws;
cout << "Number of nuts: ";
cin >> nuts;
cout << "\n\nNumber of bolts: ";
cin >> bolts;
cout << "\n\nNumber of screws: ";
cin >> screws;
system("cls");
cout << "Nuts: " << nuts << endl;
cout << "Bolts: " << nuts << endl;
cout << "Screws: " << nuts << endl;
return 0;
}
Any help would be appreciated. Thanks