Caculator?
I'm starting to learn C++ and I just made this calculator... Tell meh what you think?
Btw this is a Win32 Console app.
Btw this is a Win32 Console app.
Code:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
float a;
float b;
float s;
string choice;
string cont;
cout << "Ready to do some math?\nAdd\nSubtract\nMultiply\nDivide\n";
cin >> choice;
if (choice == "add")
{
cout << "You have Picked add.\n";
{
cout << "Type in First Number: \n";
cin >> a;
cout << "Type in Second Number: \n";
cin >> b;
cout << "\n";
cout << " " << a <<" + " << b <<" = " <<a+b <<endl;
cout << "\n";
cout << "Would you like to continue?\nYes = y\nNo = n\n";
cin >> cont;
if (cont == "y")
{
main ();
}
else (cont == "n");
{
return 0;
}
}
}
if (choice == "subtract")
{
cout << "You have Picked Subtract.\n";
{
cout << "Type in First Number: \n";
cin >> a;
cout << "Type in Second Number: \n";
cin >> b;
cout << "\n";
cout << " " << a <<" - " << b <<" = " <<a-b <<endl;
cout << "\n";
cout << "Would you like to continue?\nYes = y\nNo = n\n";
cin >> cont;
if (cont == "y")
{
main ();
}
else (cont == "n");
{
return 0;
}
}
}
if (choice == "multiply")
{
cout << "You have Picked Multiply.\n";
{
cout << "Type in First Number: \n";
cin >> a;
cout << "Type in Second Number: \n";
cin >> b;
cout << "\n";
cout << " " << a <<" * " << b <<" = " <<a*b <<endl;
cout << "\n";
cout << "Would you like to continue?\nYes = y\nNo = n\n";
cin >> cont;
if (cont == "y")
{
main ();
}
else (cont == "n");
{
return 0;
}
}
}
if (choice == "divide")
{
cout << "You have Picked Divide.\n";
{
cout << "Type in First Number: \n";
cin >> a;
cout << "Type in Second Number: \n";
cin >> b;
cout << "\n";
cout << " " << a <<" / " << b <<" = " <<a/b <<endl;
cout << "\n";
cout << "Would you like to continue?\nYes = y\nNo = n\n";
cin >> cont;
if (cont == "y")
{
main ();
}
else (cont == "n");
{
return 0;
}
}
}
char f;
cin >> f;
return 0;
}




