Here is my updated code and error messages:
I am pretty much getting the same error messages for each function I'm using. I need to validate the int data type.
Can someone please help me out?
CODE
#include <fstream>
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
using namespace std;
//declaring variables
int a;
int b;
int c;
int d;
char operation;
//calling functions
void menu(char operationType);
int addFractions(int a, int b, int c,int d);
int subtractFractions(int a, int b, int c,int d);
int multiplyFractions(int a, int b, int c,int d);
int divideFractions(int a, int b, int c,int d);
void exit();
int main();
//function menu
void menu(char operationType)
{
cout << "Welcome to the Fraction Calculator.";
cout << "This program allows you to enter in two fractions";
cout << "and will perform whatever operation you choose.";
cout << "Please enter in integer values for the variables a, b, c, and d.";
cout << "The values of b and d cannot equal zero.";
cout << "Please choose the operation you would like to perform:";
cout << "+ (addition), - (subtraction), * (multiplication), / (division), or x (exit)";
cin >> operationType; //get the request
cout << endl;
if (operationType = '+')
{
int addFractions(int a, int b, int c,int d);
}
else if (operationType = '-')
{
int subtractFractions(int a, int b, int c,int d);
}
else if (operationType = '*')
{
int multiplyFractions(int a, int b, int c,int d);
}
else if (operationType = '/')
{
int divideFractions(int a, int b, int c,int d);
}
else if (operationType = 'x')
{
exit();
}
else
{
cout << "Your input was invalid, please try again";
}
}
int addFractions(int a, int b, int c,int d)
{
cout << "Please enter the numerator for the first equation: ";
cin >> a;
cout << "Please enter the denominator for the first equation: ";
cin >> b;
cout << "Please enter the numerator for the second equation:: ";
cin >> c;
cout << "Please enter the denominator for the second equation:: ";
cin >> d;
if (b,d = 0)
{
cout << "You have entered zero, which is invalid, please try again.";
}
if (a,b,c,d != int)
{
cout << "You have entered a non-integer value, please try again.";
}
cout << a/b + c/d "=" (a*d +b*c)/(b*d);
}
int subtractFractions(int a, int b, int c,int d)
{
cout << "Please enter the numerator for the first equation: ";
cin >> a;
cout << "Please enter the denominator for the first equation: ";
cin >> b;
cout << "Please enter the numerator for the second equation:: ";
cin >> c;
cout << "Please enter the denominator for the second equation:: ";
cin >> d;
if (b,d = 0)
{
cout << "You have entered zero, which is invalid, please try again.";
}
if (a,b,c,d != int)
{
cout << "You have entered a non-integer value, please try again.";
}
cout << a/b + c/d "=" (a*d – b*c)/(b*d);
}
int multiplyFractions(int a, int b, int c,int d)
{
cout << "Please enter the numerator for the first equation: ";
cin >> a;
cout << "Please enter the denominator for the first equation: ";
cin >> b;
cout << "Please enter the numerator for the second equation:: ";
cin >> c;
cout << "Please enter the denominator for the second equation:: ";
cin >> d;
if (b,d = 0)
{
cout << "You have entered zero, which is invalid, please try again.";
}
if (a,b,c,d != int)
{
cout << "You have entered a non-integer value, please try again.";
}
cout << a/b + c/d "=" (a*c)/(b*d);
}
int divideFractions(int a, int b, int c,int d)
{
cout << "Please enter the numerator for the first equation: ";
cin >> a;
cout << "Please enter the denominator for the first equation: ";
cin >> b;
cout << "Please enter the numerator for the second equation:: ";
cin >> c;
cout << "Please enter the denominator for the second equation:: ";
cin >> d;
if (b,d = 0)
{
cout << "You have entered zero, which is invalid, please try again.";
}
if (a,b,c,d != int)
{
cout << "You have entered a non-integer value, please try again.";
}
cout << a/b + c/d "=" (a*d)/(b*c);
}
int main()
{
void menu(char operationType);
}
Error messages:
------ Build started: Project:Exercise, Configuration: Debug Win32 ------
Compiling...
code.cpp
(92) : error C2062: type 'int' unexpected
(93) : error C2143: syntax error : missing ';' before '{'
(97) : error C2143: syntax error : missing ';' before 'string'
(97) : error C2064: term does not evaluate to a function taking 1 arguments
(119) : error C2062: type 'int' unexpected
(120) : error C2143: syntax error : missing ';' before '{'
(124) : error C2143: syntax error : missing ';' before 'string'
(124) : error C2146: syntax error : missing ')' before identifier '–'
(124) : error C2064: term does not evaluate to a function taking 1 arguments
(124) : error C2059: syntax error : ')'
(146) : error C2062: type 'int' unexpected
(147) : error C2143: syntax error : missing ';' before '{'
(151) : error C2143: syntax error : missing ';' before 'string'
(151) : error C2064: term does not evaluate to a function taking 1 arguments
(173) : error C2062: type 'int' unexpected
(174) : error C2143: syntax error : missing ';' before '{'
(178) : error C2143: syntax error : missing ';' before 'string'
(178) : error C2064: term does not evaluate to a function taking 1 arguments
Build log was saved at "Exercise\Debug\BuildLog.htm"
Exercise - 18 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========