need help with calculator
Code:
// my calculator.cpp : Defines the entry point for the console application.
//
#include <iostream>
using namespace std;
int main()
{
int first, second, todo;
cout << "This is a calculator for basic math functions between two integers.\n";
cout << "What would you like to do?\n1: Addition\n2: Subtraction\n3: multiplication\n4: Division\n";
cin >> todo;
if (todo > 4)
cout << "Please enter a number 1 - 4";
cout << endl;
cout << "Please insert the two integers you would like to use: ";
cin >> first;
cin >> second;
if (todo == 1)
cout << "The answer is: " << first + second << endl;
if (todo == 2)
cout << "The answer is: " << first - second << endl;
if (todo == 3)
cout << "The answer is: " << first * second << endl;
if (todo == 4)
cout << "The answer is: " << first / second << " With a remainder of " << first % second << endl;
system("pause");
return 0;
}
when the user inputs an incorrect number for addition subtraction etc. it says "please enter a number 1 - 4" but then it just goes to the next step, how can i fix this?