Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this is an easy calculator with source code for you guys
- // i commented all of this for starters of c++
- // this calculator is able to add, subtract, multiply and divide
- // [includes]
- #include <iostream>
- #include <windows.h>
- #include <string>
- // [includes]
- // [namespaces]
- using namespace std;
- using std::cout; // more information
- using std::cin; // more information
- // [namespaces]
- // [variables]
- float variable1_add; // number 1 for add option
- float variable2_add; // number 2 for add option
- int variable1_substract; // number 1 for substract option
- int variable2_substract; // number 2 for substract option
- int variable1_multiply; // number 1 for multiply option
- int variable2_multiply; // number 2 for multiply option
- int variable1_divide; // number 1 for divide option
- int variable2_divide; // number 2 for divide option
- float total_add; // total for add
- int total_substract; // total for substract
- int total_multiply; // total for multiply
- int total_divide; // total for divide
- char switch_count; // with this you can choose types
- string show_options; // i think thats self explanatory
- string choose_type; // i think thats self explanatory
- // [variables]
- // [main class]
- int main()
- {
- cout << "Show options?\a" << endl; // shows the options
- cin >> show_options; // you can choose options there
- cout << "Here you see the different variants of this calculator. Choose a type and tell me the number" << endl; // shows the 4 options
- cout << endl; // just a new line
- // you see the following options down below
- // first number to choose then description
- cout << endl; // just a new liner
- cout << "WARNING: If you will use point numbers write with a dot: ." << endl;
- cout << "(1) Add" << endl; // with this type you can add two variables
- cout << "(2) Substract" << endl; // with this type you can substract two variables
- cout << "(3) Multiply" << endl; // with this type you can multiply two variables
- cout << "(4) Divide" << endl; // with this type you can divide two variables
- cin >> switch_count; // here you can choose options
- switch (switch_count) // this is the option menu for the 4 options above
- {
- case('1'): // add option
- {
- cout << "You have chosen add" << endl;
- cout << endl;
- cout << "Tell me the first number" << endl;
- cin >> variable1_add;
- cout << "Thanks for telling me the first number (" << variable1_add << "). Now tell me the second number" << endl;
- cin >> variable2_add;
- cout << "Now adding " << variable1_add << " and " << variable2_add << "." << endl;
- total_add = variable1_add + variable2_add;
- cout << endl;
- cout << "The total is: " << total_add << endl;
- Sleep(500);
- } break;
- case('2'): // substract option
- {
- cout << "You have chosen substract" << endl;
- } break;
- case('3'): // multiply option
- {
- cout << "You haven chosen multiply" << endl;
- } break;
- case('4'): // divide option
- {
- cout << "You have chosen divide" << endl;
- } break;
- default:
- {
- cout << "ERROR - Programm will close in 5sec" << endl;
- Sleep(5000); // with this command we can close the programm
- }
- }
- cout << endl;
- cout << "Thanks you for using wizard's Calculator" << endl;
- Sleep(10000);
- }
- // [main class]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement