//**************************************
//
//**************************************
/* Super Calculator 2002 by Kyle to help me with else if and functions*/
#include <iostream.h> //needed for cout, cin, char (basic functions)
#include <conio.h> //for getch()
#include <clrscr.h> //needed to clear the screen
/*NOTE:::::: Do not enter a wrong value for
number 1 or number 2 it will mess up the program
and force you to close it and reopen it again
I will be fixing this in a later version*/
float Add (float x,float y)
{
return (x+y); //Returns the value X+Y
}
float Sub(float x,float y)
{
return (x-y); //Returns the value X-Y
}
float Mul(float x,float y)
{
return (x*y); // Returns the value X*Y
}
float Div(float x,float y)
{
return (x/y); //Returns the value X/Y
}
int main() //The beggining of the program
{
float num1, num2; //Declaring number1 and number 2
char factor; //Declaring a char
char yn; //Declaring Char Yes OR NO
cout << "\t\t\tSuperCalc 2k2 made by Kyle C.\n\n\n"; //Prints SuperCalc 2k2 to the screen
cout << "Enter two numbers: "; //I need to know how to make this exit if i want it to
cin >> num1; //user enters 1 number && I need to know how to make it so that if a user types "D" or something he gets an error
cin >> num2; //user enters another
cout << "\n\nNumber one is, " << num1 << " and Number two is, " << num2 << "."; //Shows the user the number he has picked
cout << "\n\nWhat do you want me to do? ( + , - , * , / ): "; //Asks the user what the prog should do
cin >> factor; //Enter what the users wants to do
cout << "You have chosen to " << factor << ".\n";
if (factor == '+') //if the sign is + then do this
{
cout << num1 << factor << num2 << "=" << Add(num1, num2) << "\n";
}
else if (factor == '-') //if the sign is - then do this
{
cout << num1 << factor << num2 << "=" << Sub(num1, num2) << "\n";
}
else if (factor == '*')//if the sign is * then do this
{
cout << num1 << factor << num2 << "=" << Mul(num1, num2) << "\n";
}
else if (factor == '/')//if the sign is / then do this
{
cout << num1 << factor << num2 << "=" << Div(num1, num2) << "\n";
}
else if (factor != '-' && factor != '+' && factor != '/' && factor != '*') //if the sign is wrong then show a warning
{
cout << "Sorry I am confused with your input\n\n";
}
cout << "Do you want to continue? Y/N: "; //asks if the user wants to continue
cin >> yn; //they enter a choice
if (yn == 'n' || yn == 'N' ) //if char yn is n or N then exit the program
{
return 0;
}
else
clrscr(); //If y is pressed then clear the screen and restart
main(); //restart from main function
return 0;
}لوسمحت هذا عباره عن أله حاسبه اريد ان اضفيلها class
وشو الاشياء الي اضيفها+مأبغى اكتf.h.
الي جنب ايوستريم بس وشو الاشياء الي امسحها الي تبع .h.ابغي في برنامج class
الي يقدر يساعدني بس يقولي وشو احط فو كلاس انا اعملها
ويقولي int main
وش اضيفلها

