-OverpoweR-
Member
- Reaction score
- 13
Ellow guys, i've been messing around and also got the Code Blocks now, and i've been trying to work out with this code,
I've been struggling for an hour now but i cant seem to figure a fix for this, these are the only errors that im getting while trying to compile:
D:\PROGRAMMING SECTION\InteractiveCalculatro vCodeBlocks\Interactive Calculator\main.cpp|32|error: 'else' without a previous 'if'|
D:\PROGRAMMING SECTION\InteractiveCalculatro vCodeBlocks\Interactive Calculator\main.cpp|40|error: 'else' without a previous 'if'|
D:\PROGRAMMING SECTION\InteractiveCalculatro vCodeBlocks\Interactive Calculator\main.cpp|48|error: 'else' without a previous 'if'|
Would anyone be kind enough to spare some time and guide me through this? and/or give me some feedback on efficiency of this code
Nevermind, got it
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string answer=("Yes","yes","No","no");
string operation=("Multiply","multiply","Summarize","summarize","Substract","substract","Divide","divide");
int x,y;
cout << "Hello,my name is Alpha,please state your name before we continue: " << endl;
string name;
cin >> name;
cout << name << ", Good to meet you. Shall we Continue? (Yes or No) " << endl;
cin >> answer;
if(answer=="Yes","yes"){cout << "Alright " << name << " what would you like to do? (Multiply,summarize,substract,divide)" << endl;}
else{
if(answer=="No","no"){cout << "Alright " << name << " Hope to talk with you soon again. Have a good time!" << endl;} }
cin >> operation;
if(operation=="Multiply","multiply"){cout << "Please give me your first integer: " << endl; }
cin >> x;
cout << x << ",alright now give me your second integer: " << endl;
cin >> y;
cout << x*y << " There you go, anything else?(Multiply,summarize,substract,divide" << endl;
cin >> operation;
else{
if(answer=="Summarize","summarize"){cout << "Summarizing eh? Ok,give me your first integer: " << endl;}
cin >> x;
cout << x << ",and your second integer?" << endl;
cin >> y;
cout << x+y << ",there's your result! Got anything more challenging for me?(Multiply,summarize,substract,divide)" << endl;
cin >> operation;}
else{
if(answer=="Substract","substract"){cout << "Oh i love substracting, give me your first integer: " << endl;}
cin >> x;
cout << x << ", and your second integer?" << endl;
cin >> y;
cout << x-y << ", hows that for super speedy answer! Do you have anything else that you need me to do?(Multiply,summarize,substract,divide)" << endl;
cin >> operation;}
else{
if(answer=="Divide","divide"){cout << "Division, hmmmm, alright,give me your first integer: " << endl;}
cin >> x;
cout << x << ",what would your second integer be?" << endl;
cin >> y;
cout << x/y << ",i think i did right! I hate division... well" << name << " got anything else for me?(Multiplay,summarize,substract,divide)" << endl;
cin >> operation; }
return 0;
}
I've been struggling for an hour now but i cant seem to figure a fix for this, these are the only errors that im getting while trying to compile:
D:\PROGRAMMING SECTION\InteractiveCalculatro vCodeBlocks\Interactive Calculator\main.cpp|32|error: 'else' without a previous 'if'|
D:\PROGRAMMING SECTION\InteractiveCalculatro vCodeBlocks\Interactive Calculator\main.cpp|40|error: 'else' without a previous 'if'|
D:\PROGRAMMING SECTION\InteractiveCalculatro vCodeBlocks\Interactive Calculator\main.cpp|48|error: 'else' without a previous 'if'|
Would anyone be kind enough to spare some time and guide me through this? and/or give me some feedback on efficiency of this code
Nevermind, got it
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string answer=("Yes","yes","No","no");
string operation=("Multiply","multiply","Summarize","summarize","Substract","substract","Divide","divide");
int x,y;
cout << "Hello,my name is Alpha,please state your name before we continue: " << endl;
string name;
cin >> name;
cout << name << ", Good to meet you. Shall we Continue? (Yes or No) " << endl;
cin >> answer;
if(answer=="Yes" || "yes"){cout << "Alright " << name << " what would you like to do? (Multiply,summarize,substract,divide)" << endl;}
else{
if(answer=="No" || "no"){cout << "Alright " << name << " Hope to talk with you soon again. Have a good time!" << endl;} }
cin >> operation;
if(operation=="Multiply" || "multiply")
{cout << "Please give me your first integer: " << endl;
cin >> x;
cout << x << ",alright now give me your second integer: " << endl;
cin >> y;
cout << x*y << " There you go, anything else?(Multiply,summarize,substract,divide)" << endl;
cin >> operation;}
else{
if(answer=="Summarize" || "summarize")
{cout << "Summarizing eh? Ok,give me your first integer: " << endl;
cin >> x;
cout << x << ",and your second integer?" << endl;
cin >> y;
cout << x+y << ",there's your result! Got anything more challenging for me?(Multiply,summarize,substract,divide)" << endl;
cin >> operation;}
else{
if(answer=="Substract" || "substract")
{cout << "Oh i love substracting, give me your first integer: " << endl;
cin >> x;
cout << x << ", and your second integer?" << endl;
cin >> y;
cout << x-y << ", hows that for super speedy answer! Do you have anything else that you need me to do?(Multiply,summarize,substract,divide)" << endl;
cin >> operation;}
else{
if(answer=="Divide","divide")
{cout << "Division, hmmmm, alright,give me your first integer: " << endl;
cin >> x;
cout << x << ",what would your second integer be?" << endl;
cin >> y;
cout << x/y << ",i think i did right! I hate division... well" << name << " got anything else for me?(Multiplay,summarize,substract,divide)" << endl;
cin >> operation; } } } }
return 0;
}