Hey guys, I cannot figure out how to fix this to where it works. I am supposed to get 2 numbers then have the person choose what they want to do to the numbers. Here is the code:
//Mike Karbowiak
//12/24/13
//Mathematics
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
usingnamespace std;
void hello();
float menu();
float Add(float num1, float num2);
float Subtract(float num1, float num2);
float Multiply(float num1, float num2);
float Divide(float num1, float num2);
void Output(float total1);
int goodbye();
int main(){
system ("Color C");
float num1;
float num2;
hello();
cout<< "Hello, today we are going to deal with some mathematics.\n\n";
cout<< "Please enter two numbers. (hit enter after you input the first number)\n\n";
cin>>num1;
cin>>num2;
float total = menu();
system("cls");
Output(total);
goodbye();
return(0);
}
void hello()
{
system("Color C");
cout<<"\t\t\t*******************************\n";
cout<<"\t\t\t* *\n";
cout<<"\t\t\t* Hello, my name is Mike *\n";
cout<<"\t\t\t* *\n";
cout<<"\t\t\t* I am Lord and Master *\n";
cout<<"\t\t\t* *\n";
cout<<"\t\t\t*******************************\n" <<endl;
}
float menu() { //displays the food and drink items available
int answer;
float total = 0;
cout<< "What would you like to do?" << "\n\n";
cout<< "Please input the number that corresponds with your choice." << "\n\n";
cout<< "\t\t\t Food \n" <<endl;
cout<< "[1] Add" << '\t' << "[2] Subtract" << "\n\n";
cout<< "[3] Multiply" << '\t' << "[4] Divide" << "\n\n";
cin>>answer;
switch(answer)
{
case 1:
total = Add();
Output(total);
//output_case = 1;
break;
case 2:
total = Subtract();
//output_case = 2;
break;
case 3:
total = Multiply();
//output_case = 3;
break;
case 4:
total = Divide();
//output_case = 4;
break;
}
return (total);
}
float Add(float num1, float num2) {
//float num1;
//float num2;
float sum=0;
float num = 0;
sum = num1 + num2;
return(sum);
}
float Subtract(float num1, float num2) {
//float num1;
//float num2;
float diff=0;
float num = 0;
diff = num2 - num1;
}
float Multiply(float num1, float num2) {
//float num1;
//float num2;
float product=0;
float num = 0;
product = num1 * num2;
}
float Divide(float num1, float num2) {
//float num1;
//float num2;
float quotient=0;
float num = 0;
quotient = num2 / num1;
}
void Output(float total) {
float answer=total;
cout<<"\nYou're answer is " << answer << endl;
system ("pause");
system ("cls");
}
int goodbye(){
//system("cls");
int again = 1; //local variables
cout<<"Do you want to run again? ";
cout<<"Enter 1 for yes, 0 for no \n";
cin>>again;
if(again==1)
main();
if(again==0)
return (0);
}
The errors I am getting so far are:
error C2660: 'Add' : function does not take 0 arguments
error C2660: 'Subtract' : function does not take 0 arguments
error C2660: 'Multiply' : function does not take 0 arguments
error C2660: 'Divide' : function does not take 0 arguments
You're missing the return statements to some of your functions.
On lines 83-106, what do you expect to happen? The compiler will not turn into a human and say "I suppose he wants to ask the user for two values, pass those two values to each of these function calls, and then tell the user about the returned values".
Also, what is line 154 for? There's no reason to do that.