#include <iostream>
using namespace std;
int main( )
{
restart:
int a,b,c,x;
cout << "Welcome to the advanced arithmetic calculator.\n What do you want to do?\n 1)Add\n 2)Sub\n 3)Mul\n 4)Div\n \n " ;
cin >> x;
if ( x== 1 || x== 2 || x== 3 || x== 4 )
{
cout << "\n Enter first number.\n \n " ;
cin >> a;
cout << "\n Enter second number.\n \n " ;
cin >> b;
if ( x== 1 )
{
c= a+ b;
}
else if ( x== 2 )
{
c= a- b;
}
else if ( x== 3 )
{
c= a* b;
}
else if ( x== 4 && b! = 0 )
{
c= a/ b;
}
else if ( x== 4 && b== 0 )
{
cout << "\n UNDEFINED.\n \n " ;
goto restart;
}
cout << endl<< c << " is the answer.\n \n " ;
}
else
{
cout << "\n ERROR\n \n -------------\n \n " ;
goto restart;
}
//-------------------------End of first calc
cout << "What would you like to do next? Would you like to 1)Restart or 2)Exit?\n \n " ;
cin >> x;
if ( x== 1 )
{
goto restart;
}
else
{
cout << "\n Bye.\n \n " ;
return 0 ;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCgppbnQgbWFpbigpCnsKICByZXN0YXJ0OgogIGludCBhLGIsYyx4OwoKICBjb3V0IDw8ICJXZWxjb21lIHRvIHRoZSBhZHZhbmNlZCBhcml0aG1ldGljIGNhbGN1bGF0b3IuXG5XaGF0IGRvIHlvdSB3YW50IHRvIGRvP1xuMSlBZGRcbjIpU3ViXG4zKU11bFxuNClEaXZcblxuIjsKICBjaW4gPj4geDsKCiAgaWYoeD09MXx8eD09Mnx8eD09M3x8eD09NCkKICB7CiAgICAgIGNvdXQgPDwgIlxuRW50ZXIgZmlyc3QgbnVtYmVyLlxuXG4iOwogICAgICBjaW4gPj4gYTsKCiAgICAgIGNvdXQgPDwgIlxuRW50ZXIgc2Vjb25kIG51bWJlci5cblxuIjsKICAgICAgY2luID4+IGI7CgogICAgICBpZih4PT0xKQogICAgICB7CiAgICAgICAgYz1hK2I7CiAgICAgIH0KCiAgICAgIGVsc2UgaWYoeD09MikKICAgICAgewogICAgICAgICAgYz1hLWI7CiAgICAgIH0KCiAgICAgIGVsc2UgaWYoeD09MykKICAgICAgewogICAgICAgICAgYz1hKmI7CiAgICAgIH0KICAgICAgZWxzZSBpZih4PT00ICYmIGIhPTApCiAgICAgIHsKICAgICAgICAgIGM9YS9iOwoKICAgICAgfQogICAgICBlbHNlIGlmKHg9PTQgJiYgYj09MCkKICAgICAgewogICAgICAgICAgY291dCA8PCAiXG5VTkRFRklORUQuXG5cbiI7CiAgICAgICAgICBnb3RvIHJlc3RhcnQ7CiAgICAgIH0KCiAgICAgIGNvdXQgPDxlbmRsPDwgYyA8PCIgaXMgdGhlIGFuc3dlci5cblxuIjsKICB9CiAgZWxzZQogIHsKICAgICAgY291dCA8PCAiXG5FUlJPUlxuXG4tLS0tLS0tLS0tLS0tXG5cbiI7CiAgICAgIGdvdG8gcmVzdGFydDsKICB9CgogIC8vLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLUVuZCBvZiBmaXJzdCBjYWxjCgogIGNvdXQgPDwiV2hhdCB3b3VsZCB5b3UgbGlrZSB0byBkbyBuZXh0PyBXb3VsZCB5b3UgbGlrZSB0byAxKVJlc3RhcnQgb3IgMilFeGl0P1xuXG4iOwogIGNpbiA+PiB4OwoKICBpZih4PT0xKQogIHsKICAgICAgZ290byByZXN0YXJ0OwogIH0KCiAgZWxzZQogIHsKICAgICAgY291dCA8PCAiXG5CeWUuXG5cbiI7CiAgICAgIHJldHVybiAwOwogIH0KfQ==