Hello, this is kinda my first program. I would like to know how to clean the screen so only this code would stay in the console
cout<<"Welcome to calculator!\n\n";
cout<<"[*] - a * b\n[/] - a / b\n[-] - a - b\n[+] - a + b\n\n";
I m also having trouble that when i make wrong ccalculation suchs as 5+5+, the program is looping the 5 + 5 calculation and ignores any input.
#include <iostream>
using namespace std;
int main ()
{
double a;
double b;
char oper;
int exit = 0;
cout<<"Welcome to calculator!\n\n";
cout<<"[*] - a * b\n[/] - a / b\n[-] - a - b\n[+] - a + b\n\n";
do {
cout<<"Calculator is now ready to calculate\n\n";
cin>>a >>oper >>b;
cout<<endl;
if (oper == '+')
{
cout<<a<<" + "<<b<<" = "<<a+b<<endl<<endl;
cout<<"Press 1 to exit or 0 to continue: ";
cin>>exit;
cout<<endl;
}
else if (oper == '-')
{
cout<<a-b;
}
else if (oper == '*')
{
cout<<a*b;
}
else if (oper == '/')
{
cout<<a/b;
}
else
{
cerr<<"Not a valid operation. Try again\n\n";
}
}while (exit < 1);
cout<<"Thank you for using...Press any key.... \n";
return 0;
}