#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;
void Options(int input) {
switch(input) {
case 1:
cout << "This is case 1!" << endl;
break;
case 2:
cout << "This is case 2!" << endl;
break;
case 3:
cout << "This is case 3!" << endl;
break;
case 4:
cout << "This is case 4!" << endl;
break;
default:
cout << "This is the defualt case!" << endl;
cout << "When there is an empty, missing, or invalid input; I'm the first option!" << endl;
}
}
int main() {
string INPUT;
cout << "Enter an int input:" << endl;
cin >> INPUT;
int input;
try {
input = stoi(INPUT);
} catch(const invalid_argument& e) {
cerr << "Invalid value; must be numeric!";
return 1;
}
Options(input);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: