I have to create a simple calculator and I dont know what I am doing wrong!
The code I have so far, there are 23 errors I got it down from 42! Now I am stuck and dont know which way is up or down!
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
namespace calcu{
fNumbr = 0;
sNumbr = 0;
enum menOptions {Exit, Addition, Subtraction, Division, Multiplcation, Modulus};
int main(void){
cout<<endl<<"A simple calculator!\n";
cout<<endl<<"Enter first number: \n";
cin>>firstNumber;
cout<<endl<<"Enter the second number: \n";
cin>>secondNumber;
int usersChoice=0;
cout<<endl<<"Choose your calculation option:\n\n";
cout << "Choose a Calculation Option:\n\n";
cout << calcu::Addition<<" - Addition\n";
cout << calcu::subtraction<<" - Subtraction\n";
cout << calcu::division<<" - Division\n";
cout << calcu::multiplcation<<" - Multiplcation\n";
cout << calcu::modulus<<" - Modulus\n";
cout << calcu::Exit << " - Exit\n";
cout << "Enter a number: ";
cin >> usersChoice;
if (usersChoice < 0 || usersChoice > 5){
cout << endl << "Invalid choice - program terminated\n\n";
struct calcuType {double addition; double subtraction; double division; double multiplcation double modulus;};
calcuType myCalcu;
myCalcu.addition = fNumbr+sNumbr;
myCalcu.subtraction = fNumbr-sNumbr;
myCalcu.division = fNumbr/sNumbr;
myCalcu.multiplcation = fNumbr*sNumbr;
myCalcu.modulus = fsum(fNumbr,sNumbr);
switch (usersChoice) {
case calcu::Exit:
cout << endl << "You choose to exit the program\n\n"; break;
case calcu::Addition:
cout << endl
<< " "
<< fNumbr
<< " + "
<<" "
<< sNumbr
<<myCalcu.addition << "\n\n"; break;
case calcu::subtraction:
cout << endl
<< " "
<< fNumbr
<< " - "
<<" "
<< sNumbr
<<myCalcu.subtraction << "\n\n"; break;
case calcu::division:
cout << endl
<< " "
<< fNumbr
<< " / "
<<" "
<< sNumbr
<<myCalcu.division << "\n\n"; break;
case calcu::multiplcation:
cout << endl
<< " "
<< fNumbr
<< " * "
<<" "
<< sNumbr
<<myCalcu.multiplcation << "\n\n"; break;
case calcu::modulus:
cout << endl
<< " "
<< fNumbr
<< " % "
<<" "
<< sNumbr
<<myCalcu.modulus << "\n\n"; break;
default:
cout << endl << "Not a valid choose!\n\n";
{
cout << endl << endl << "end of program\n\n";
}
return 0;