السلام عليكم ورحمة الله وبركاتة
كيفكم يا اخوانى أتمنى يكون الجميع بخير
أقدم لكم برنامج بسيط عبارة عن اله حاسبة ولكنها تحتوى على كثير من الافكار وأنتظر من حضراتكم التعليق على الكود
#include<iostream>
using namespace std;
int main()
{
float a,b;
int firstchoice;
char secondchoice;
cout<<" hello user how are you"<<endl<<" this simple calculator v1.2"<<endl;
again:
again1:
cout<<"please choice between"<<endl<<"1-login to calulator now"<<endl<<"2-to know about me who write this program"<<endl<<"3-close this program"<<endl<<"Enter your choice number here =";
cin>>firstchoice;
if(cin.fail()==true)
{
cin.clear();
cin.ignore(1024, '\n');
cout<<"you must Enter number like 1,2,3"<<endl;
goto again1;
}
else
switch (firstchoice)
{
case 1:
firstErr:
cout<<"please Enter frist number =";
cin>>a;
if (cin.fail()==true)
{
cin.clear();
cin.ignore ( 1024, '\n' );
cout<<"Error you must input number try input again"<<endl;
goto firstErr;
}
else
cout<<"please Enter second numbe=";
cin>>b;
if (cin.fail()==true)
{
cin.clear();
cin.ignore (1024, '\n');
cout<<"Error you must input number try input again"<<endl;
goto firstErr;
}
else
cout<<"please type operation you want like +,-,*,/,"<<endl<<"write your choice =";
cin>>secondchoice;
switch (secondchoice)
{
case '+':cout<<"---------------"<<endl<<"your mithod is "<<a<<"+"<<b<<"="<<a+b<<endl<<"---------------"<<endl;goto again;break;
case '-':cout<<"---------------"<<endl<<"your mithod is "<<a<<"-"<<b<<"="<<a-b<<endl<<"---------------"<<endl;goto again;break;
case '*':cout<<"---------------"<<endl<<"your mithod is "<<a<<"*"<<b<<"="<<a*b<<endl<<"---------------"<<endl;goto again;break;
case '/':
if (b<=0)
{
cout<<"Error it can't ( "<<a<<"/0 )"<<"how it's come??"<<endl;
goto firstErr;
}
else
cout<<"---------------"<<endl<<"your mithod is "<<a<<"/"<<b<<"="<<a/b<<endl<<"---------------"<<endl;goto again;break;
default:cout<<"sorry unknown Error please just choice between +,-,*,/"<<endl;goto again;break;
}
case 2:cout<<"------------------"<<endl<<"myname= mohamed elhabashe"<<endl<<"fromwhere= Egypt"<<endl<<"myage= 25 years"<<endl<<"------------------"<<endl;goto again;break;
case 3:cout<<"thx for watching bye bye"<<endl;break;
default:cout<<"Error you must input number between (1 to 3)"<<endl;goto again;
}
system("pause");
return 0;
}






