Console C++ to full Windows
Alright heres the situation: I have made a console based calculator and I need to move it all into windows program. The following code is what I have so far in Windows code.
Code:// First Windows Program // This program is intended to display a Windows XP themed interface // and use some basic Windows program functions #define STRICT #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <iostream> #include <string> int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { using namespace std; MessageBox(NULL, "Would you like to do some math?", "Calculator", MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND); return 0; } This is my calculator code: // Calculator // Include files below #include <iostream> #include <string> #include <math.h> #include <cstdlib> using namespace std; //Beginning of calulator int main() { //Mathematical operators' corresponding number //Done = 5; //Subtraction = 4; //Addition = 3; //Multiplication = 2; //Division = 1; int answer; //Answer must be initialized to be used cout << "What basic mathematical operator shall I perform ?" << endl; cout << "Please answer with: Division(1), Multiplication(2), Addition(3), Subtraction(4)" << endl; cout << "Square Root(5), Sine(6), Cosine(7), Tangent(8), Exponetial(9) or End Program(10)" << endl; cout << "Want a operator not seen here? More operators can be added at your request!" << endl; cin >> answer; while(answer!=10) // This begins a loop that will only end when answer is equal to 10 { if (answer == 1) //Division section of the calculator { // Long double is the type of variable that can have up to 15 digits // Again variables must be initialized before using them. // However because of the braces around this section the variables // are local and can be initialized/used in other sections again long double value1; long double value2; // This asks for values and then inputs the values into the variables cout << "Input value to be divided: "; cin >> value1; cout << "Input the dividend: "; cin >> value2; //Dividing the values and storing the answer to value1 value1 /= value2; cout << "Answer: "<< value1 << endl <<endl; cout << "Please input the next operation number you would like to preform." << endl; cin >> answer; } if (answer == 2) //Multiplication section of the calculator { long double value1; long double value2; cout << "Input first number: "; cin >> value1; cout << "Input the second number: "; cin >> value2; value1*=value2; cout << "Answer: "<< value1 << endl <<endl; cout << "Please input the next operation number you would like to preform." << endl; cin >> answer; } if (answer == 3) //Addition section of the calculator { long double value1; long double value2; cout << "Input the first number : "; cin >> value1; cout << "Input the second number: "; cin >> value2; value1+=value2; cout << "Answer: "<< value1 << endl <<endl; cout << "Please input the next operation number you would like to preform." << endl; cin >> answer; } if (answer == 4) //Subtraction section of the calculator { long double value1; long double value2; cout << "Input value to be subtracted from: "; cin >> value1; cout << "Input the number to subtract from the first: "; cin >> value2; value1-=value2; cout << "Answer: "<< value1 << endl <<endl; cout << "Please input the next operation number you would like to preform." << endl; cin >> answer; } if (answer == 5) //root section of the calculator { long double value1; long double value2; cout << "Input value to be square rooted: "; cin >> value1; value2 = sqrt (value1); cout << "Answer: "<< value2 << endl <<endl; cout << "Please input the next operation number you would like to preform." << endl; cin >> answer; } if (answer == 6) //sine section of the calculator { long double value1; long double value2; cout << "Input value to get the sine for: "; cin >> value1; value2 = sin (value1); cout << "Answer: "<< value2 << endl <<endl; cout << "Please input the next operation number you would like to preform." << endl; cin >> answer; } if (answer == 7) //cosine section of the calculator { long double value1; long double value2; cout << "Input value to get the cosine for: "; cin >> value1; value2 = cos (value1); cout << "Answer: "<< value2 << endl <<endl; cout << "Please input the next operation number you would like to preform." << endl; cin >> answer; } if (answer == 8) //tangent section of the calculator { long double value1; long double value2; cout << "Input value to get the tangent for: "; cin >> value1; value2 = tan (value1); cout << "Answer: " << value2 << endl <<endl; cout << "Please input the next operation number you would like to preform." << endl; cin >> answer; } if (answer == 9) //exponetial section of the calculator { long double value1; long double value2; cout << "Input value to raise exponentially: "; cin >> value1; cout << "Input exponet: "; cin >> value2; cout << "Answer: "<< pow (value1,value2)<< endl <<endl; cout << "Please input the next operation number you would like to preform." << endl; cin >> answer; } else { cout << "Please input a correct number" << endl; cin >> answer; } // Braces are needed at each level of abstraction } // Return value shows that program executed as expected and then ends the program return 0; }
http://domain-name5.blogspot.com/200...n-limited.html



LinkBack URL
About LinkBacks



