Oct 1, 2016 02:36 PM
(This post was last modified: Oct 1, 2016 03:39 PM by D_MuLa.)
Everything looks okay except my multiplication table doesn't seem to be formatting properly EDIT i fixed my table, but my while loop at the end doesn't seem to be executing. So i could use some expertise :)
Code
#include <iostream>
#include <string>
using namespace std;
int main()
{
string calculatoropt;
string multitableopt;
string input;
cout << " Please choose an option: "<< endl;
cout << " 1. Calculator" << endl;
cout << " 2. Multiplication Table" << endl;
cin >> input;
if( input =="1" )
{
int firstnumber;
int secondnumber;
cout << " Enter the first number: " << endl;
cin >> firstnumber;
cout << " Enter the second number: " << endl;
cin >> secondnumber;
cout << firstnumber << " * " << secondnumber << "=" << firstnumber * secondnumber << endl;
cout << firstnumber << " + " << secondnumber << "=" << firstnumber + secondnumber << endl;
cout << firstnumber << " / " << secondnumber << "=" << firstnumber / secondnumber << endl;
cout << firstnumber << " - " << secondnumber << "=" << firstnumber - secondnumber << endl;
}
else if( input == "2" )
{
for (int i = 0; i < 10; i++)
{
cout << '\t' << i;
}
cout << 'endl';
for (int i = 0; i < 10; ++i)
{
cout << i;
for (int j = 0; j < 10; ++j)
{
cout << '\t' << i * j << endl;
}
cout << endl;
}
while( input != "1" && input!= "2")
{
cout << "Sorry, you've entered an invalid option" << endl;
cin >> input;
return 0;
}
}
}

