So I have to create a program to use a Printmenu, allowing the user to choose option 1 2 3. The problem I am stuck on is figuring out how to allow the user enter 2 numbers which are to be multiplied if they select the first option. Another problem is that when I try to compile and run the program, it gives me an error saying:
"31 no match for 'operator>>' in '(&std::cin)->std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((int&)(&x))) >> std::endl' "
Here is what I have written so far.
#include <cstdlib>
#include <iostream>
void print_menu();
int multiply_2_numbers(int, int);
double devide_2_numbers(int, int);
void half_number(int);
using namespace std;
int main()
{
int input = 0;
int x;
int y;
int temp=multiply_2_numbers(x,y);
do{
print_menu();
cout<<"Enter a number 1 through 3 to open one of the following options"<< endl;
cin>> input;
switch(input)
{
case(1):
cout<< "Enter 1st number you want to multiply"<< endl;
cin>> x >> endl;
cout<< "Enter 2nd number you want to multiply"<< endl;
cin>> y>> endl;
cout<< temp;
break;
case '2':
divide_2_numbers
break;
case '3':
//case 3 code
break;
case '4': //case 4 code exits
return EXIT_SUCCESS;
default:
cout << "User Entry Not Valid!!! Try Again...";
}
}while(input !=4);
system("PAUSE");
return EXIT_SUCCESS;
}
void print_menu(){
cout<< "Option 1 is to multiply 2 numbers"<< endl;
cout<< "Option 2 is to divide 2 numbers"<< endl;
cout<< "Option 3 divides the number in half until it reaches 1"<< endl;
cout<< "Option 4 closes the program"<< endl;
}
int multiply_2_numbers(int x, int y){
int result = 0;
result=x*y;
return result;
}
double divide_2_numbers(int x, int y){
double result = 0;
result=x/y;
return result;
}
void half_number(int number){
//cout number being half-ed in a loop until you reach 1