Advertisement
ItsWolfiy

C++ Calculator (v2.4.2)

Mar 19th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 14.73 KB | None | 0 0
  1. DOWNLOAD LINK:
  2. https://mega.nz/#!BdNTDY7B!bwlGx0K3w9VjGBostimSftiixfbS05rcI7Oweohetgs
  3.  
  4. ===========================================================================
  5.  
  6.  
  7. #include <iostream>
  8. #include <stdio.h>
  9. #include <windows.h>
  10. #include <math.h>
  11. #include <iomanip>
  12. #include <fstream>
  13. #include <conio.h>
  14.  
  15. #include "resource.h"
  16.  
  17. using namespace std;
  18.  
  19. int convertionDegrees();
  20. int areaOfTriangle();
  21. int areaOfCircle();
  22. int areaOfRectangle();
  23. int converter();
  24. int areas();
  25. int otherOperations();
  26. int linksAndStuff();
  27. int help();
  28.  
  29. //MAIN FUNCTION/BASIC CALCULATION
  30. int main()
  31. {
  32.     system("mode 70, 23");
  33.     SetConsoleTitle("C++ CALCULATOR by Wolfiy v2.4.2");
  34.  
  35.     double num1, num2;
  36.  
  37.     for (int choiceFirstPage; choiceFirstPage != 1 || 2 || 3 || 4 || 5 || 6 || 9;){
  38.         system("cls");
  39.         cout << "\n\n Please select what do you want to do:\n\n" << endl;
  40.         cout << "\11" << "1. Addition\n\n" << "\11" << "2. Subtraction\n\n" << "\11" << "3. Multiplication\n\n"
  41.         << "\11" << "4. Division\n\n" << "\11" << "5. Links and other stuff\n\n" << "\11" << "6. More\n\n" << "\11" << "7. Help\n\n\n            9. Leave\n\n" << endl;
  42.         cin >> choiceFirstPage;
  43.  
  44.             switch(choiceFirstPage){
  45.             case 1:
  46.                 {
  47.                     system("cls");
  48.                     cout << "\n\n Select two numbers you'd like to add:\n" << endl;
  49.                     cout << "\11"; cin >> num1;
  50.                     cout << "\11"; cin >> num2;
  51.                     cout << "\n\11" << num1 << " + " << num2 << " = " << num1+num2 << endl;
  52.                     cin.ignore();
  53.                     getchar();
  54.                     break;
  55.                 }
  56.             case 2:
  57.                 {
  58.                     system("cls");
  59.                     cout << "\n\n Select two numbers you'd like to subtract:\n" << endl;
  60.                     cout << "\11"; cin >> num1;
  61.                     cout << "\11"; cin >> num2;
  62.                     cout << "\n\11" << num1 << " - " << num2 << " = " << num1-num2 << endl;
  63.                     cin.ignore();
  64.                     getchar();
  65.                     break;
  66.                 }
  67.             case 3:
  68.                 {
  69.                     system("cls");
  70.                     cout << "\n\n Select two numbers you'd like to multiply:\n" << endl;
  71.                     cout << "\11"; cin >> num1;
  72.                     cout << "\11"; cin >> num2;
  73.                     cout << "\n\11" << num1 << " * " << num2 << " = " << num1*num2 << endl;
  74.                     cin.ignore();
  75.                     getchar();
  76.                     break;
  77.                 }
  78.             case 4:
  79.                 {
  80.                     system("cls");
  81.                     cout << "\n\n Select two numbers you'd like to divide:\n" << endl;
  82.                     cout << "\11"; cin >> num1;
  83.                     cout << "\11"; cin >> num2;
  84.                     cout << "\n\11" << num1 << " / " << num2 << " = " << num1/num2 << endl;
  85.                     cin.ignore();
  86.                     getchar();
  87.                     break;
  88.                 }
  89.             case 5:
  90.                 {
  91.                     linksAndStuff();
  92.                     break;
  93.                 }
  94.             case 6:
  95.                 {
  96.                     otherOperations();
  97.                     break;
  98.                 }
  99.             case 7:
  100.                 {
  101.                     help();
  102.                     break;
  103.                 }
  104.             case 9:
  105.                 {
  106.                     exit(0);
  107.                 }
  108.             default:
  109.                 {
  110.                     system("cls");
  111.                     cout << "\n     [ERROR]\n\n\n               This isn't a valid choice!\n\n" << endl;
  112.                     getchar();
  113.                     break;
  114.                 }
  115.             }
  116.     }
  117.  
  118.     return 0;
  119. }
  120.  
  121. int help(){
  122.  
  123.     string install;
  124.     for (int choiceHelp; choiceHelp != 1|| 2 || 3;){
  125.         system("cls");
  126.         cout << "\n\n Please select something:\n\n" << endl;
  127.         cout << "\11" << "1. Correct Installation\n\n\11" << "2. Shortcut\n\n\11" << "3. Get the calculator in the Windows search\n\n\n\n\n\n\n\n\n\n 8. Back    9. Leave\n\n" << endl;
  128.         cin >> choiceHelp;
  129.         switch(choiceHelp){
  130.         case 1:
  131.             {
  132.                     ShellExecute(0, "open", "Files\\installation.txt", 0, 0, SW_SHOWNORMAL);
  133.                     break;
  134.             }
  135.         case 2:
  136.             {
  137.                     ShellExecute(0, "open", "Files\\shortcut.txt", 0, 0, SW_SHOWNORMAL);
  138.                     break;
  139.             }
  140.         case 3:
  141.             {
  142.                     ShellExecute(0, "open", "Files\\in_windows_search.txt", 0, 0, SW_SHOWNORMAL);
  143.                     break;
  144.             }
  145.         case 8:
  146.             {
  147.                     main();
  148.                     break;
  149.             }
  150.         case 9:
  151.             {
  152.                 exit(0);
  153.             }
  154.  
  155.         }
  156.     }
  157.  
  158.     return 0;
  159. }
  160.  
  161. int linksAndStuff(){
  162.  
  163.     for (long choiceLinksAndStuff; choiceLinksAndStuff != 1|| 2 || 3 || 5 || 9 || 1000101;){
  164.         system("cls");
  165.         cout << "\n\n Please select what you'd like to see:\n\n" << endl;
  166.         cout << "\11" << "1. YouTube\n\n\11" << "2. Instagram\n\n\11" << "3. Pastebin\n\n\11" << "4. Source code\n\n\11"
  167.         << "5. 1st Version Source Code\n\n\n\n\n\n 8. Back    9. Leave\n\n" << endl;
  168.         cin >> choiceLinksAndStuff;
  169.  
  170.         if (choiceLinksAndStuff == 1000101){
  171.                     ShellExecute(0, "open", "Files\\That's not an easter egg.exe", 0, 0, SW_SHOWNORMAL);
  172.         }
  173.         else if (choiceLinksAndStuff == 1){
  174.                     ShellExecute(0, "open", "https://www.YouTube.com/DarkWolfiiy", 0, 0, SW_SHOWNORMAL);
  175.             }
  176.         else if (choiceLinksAndStuff == 2){
  177.                     ShellExecute(0, "open", "https://www.Instagram.com/Page4Bronies", 0, 0, SW_SHOWNORMAL);
  178.             }
  179.         else if (choiceLinksAndStuff == 3){
  180.                     ShellExecute(0, "open", "https://pastebin.com/u/ItsWolfiy", 0, 0, SW_SHOWNORMAL);
  181.             }
  182.         else if (choiceLinksAndStuff == 4){
  183.                     ShellExecute(0, "open", "Files\\Source Codes\\Source Code.txt", 0, 0, SW_SHOWNORMAL);
  184.             }
  185.         else if (choiceLinksAndStuff == 5){
  186.                     ShellExecute(0, "open", "Files\\Source Codes\\Source Code (v.1).txt", 0, 0, SW_SHOWNORMAL);
  187.             }
  188.         else if (choiceLinksAndStuff == 8){
  189.                     main();
  190.             }
  191.         else if (choiceLinksAndStuff == 9){
  192.                     exit(0);
  193.             }
  194.         else{
  195.                     system("cls");
  196.                     cout << "\n     [ERROR]\n\n\n               This isn't a valid choice!\n\n" << endl;
  197.                     getchar();
  198.             }
  199.         }
  200.  
  201.     return 0;
  202. }
  203.  
  204. //2ND PAGE OF POSSIBILITIES/MODULO/POWERS/OTHERS
  205. int otherOperations()
  206. {
  207.     int modulo1, modulo2;
  208.     double numToPow, power;
  209.  
  210.     for (int choiceSecondPage; choiceSecondPage != 1 || 2 || 3 || 4 || 8 || 9;){
  211.         system("cls");
  212.         cout << "\n\n Please select what do you want to do:\n\n" << endl;
  213.         cout << "\11" <<"1. Modulo\n\n" << "\11" << "2. Powers\n\n" << "\11" << "3. Areas\n\n" << "\11" <<"4. Converter\n\n\n\n\n\n\n\n 8. Back    9. Leave\n\n" << endl;
  214.         cin >> choiceSecondPage;
  215.  
  216.             switch(choiceSecondPage){
  217.             case 1:
  218.                 {
  219.                     system("cls");
  220.                     cout << "\n\n Select two numbers you'd like the modulo:\n" << endl;
  221.                     cout << "\11"; cin >> modulo1;
  222.                     cout << "\11"; cin >> modulo2;
  223.                     cout << "\n\11" << modulo1 << " % " << modulo2 << " = " << modulo1%modulo2 << endl;
  224.                     cin.ignore();
  225.                     getchar();
  226.                     break;
  227.                 }
  228.             case 2:
  229.                 {
  230.                     system("cls");
  231.                     cout << "\n\n Select the number you'd like to know the power:\n" << endl;
  232.                     cout << "\11"; cin >> numToPow;
  233.                     cout << "\n\n Select the power you want:\n" << endl;
  234.                     cout << "\11"; cin >> power;
  235.                     cout << "\n\11" << numToPow << " ^ " << power << " = " << pow(numToPow, power) << endl;
  236.                     cin.ignore();
  237.                     getchar();
  238.                     break;
  239.                 }
  240.             case 3:
  241.                 {
  242.                     areas();
  243.                     break;
  244.                 }
  245.             case 4:
  246.                 {
  247.                     converter();
  248.                     break;
  249.                 }
  250.             case 8:
  251.                 {
  252.                     main();
  253.                     break;
  254.                 }
  255.             case 9:
  256.                 {
  257.                     exit(0);
  258.                 }
  259.             default:
  260.                 {
  261.                     system("cls");
  262.                     cout << "\n     [ERROR]\n\n\n               This isn't a valid choice!\n\n" << endl;
  263.                     getchar();
  264.                     break;
  265.                 }
  266.             }
  267.     }
  268.     return 0;
  269. }
  270.  
  271. //CONVERTER
  272. int converter(){
  273.  
  274.     for (int choiceConverter; choiceConverter != 1 || 2 || 3;){
  275.         system("cls");
  276.         cout << "\n\n Please select what you'd like to do:\n\n" << endl;
  277.         cout << "\11" << "1. Degrees\n\n\n\n\n\n\n\n 8. Back    9. Leave\n\n" << endl;
  278.         cin >> choiceConverter;
  279.  
  280.             switch(choiceConverter){
  281.             case 1:
  282.                 {
  283.                     convertionDegrees();
  284.                     break;
  285.                 }
  286.             case 8:
  287.                 {
  288.                     otherOperations();
  289.                     break;
  290.                 }
  291.             case 9:
  292.                 {
  293.                     exit(0);
  294.                 }
  295.             }
  296.     }
  297.  
  298.     return 0;
  299. }
  300.  
  301. //AREAS
  302. int areas(){
  303.  
  304.     for (int choiceAreas; choiceAreas != 1 || 2 || 3 || 4 || 8 || 9;){
  305.         system("cls");
  306.         cout << "\n\n Please select what area you'd like to calculate:\n\n" << endl;
  307.         cout << "\11" << "1. Square\n\n" << "\11" << "2. Rectangle\n\n" << "\11" << "3. Circle\n\n" << "\11" << "4. Triangle\n\n\n\n\n\n\n\n 8. Back    9. Leave\n\n" << endl;
  308.         cin >> choiceAreas;
  309.  
  310.             switch(choiceAreas){
  311.             case 1:
  312.                 {
  313.                     double squareSide;
  314.                     system("cls");
  315.                     cout << "\n\n Please, insert the length of the side of the square:\n\n" << endl;
  316.                     cout << "\11"; cin >> squareSide;
  317.                     cout << "\n\11" << squareSide << " ^ 2 = " << pow(squareSide, 2) << endl;
  318.                     cin.ignore();
  319.                     getchar();
  320.                     break;
  321.                 }
  322.             case 2:
  323.                 {
  324.                     areaOfRectangle();
  325.                     break;
  326.                 }
  327.             case 3:
  328.                 {
  329.                     areaOfCircle();
  330.                     break;
  331.                 }
  332.             case 4:
  333.                 {
  334.                     areaOfTriangle();
  335.                     break;
  336.                 }
  337.             case 8:
  338.                 {
  339.                     otherOperations();
  340.                     break;
  341.                 }
  342.             case 9:
  343.                 {
  344.                     exit(0);
  345.                 }
  346.             default:
  347.                 {
  348.                     system("cls");
  349.                     cout << "\n     [ERROR]\n\n\n               This isn't a valid choice!\n\n" << endl;
  350.                     getchar();
  351.                     break;
  352.                 }
  353.             }
  354.     }
  355.  
  356.     return 0;
  357. }
  358.  
  359. //AREA OF RECTANGLES
  360. int areaOfRectangle(){
  361.  
  362.     double width;
  363.     double height;
  364.     system("cls");
  365.     cout << "\n\n Please, insert the width of your rectangle:\n" << endl;
  366.     cout << "\11"; cin >> width;
  367.     cout << "\n\n Now insert the height of your rectangle:\n" << endl;
  368.     cout << "\11"; cin >> height;
  369.     double areaRectangle = width*height;
  370.     cout << "\n\11" << width << " * " << height << " = " << areaRectangle << endl;
  371.     cin.ignore();
  372.     getchar();
  373.  
  374.     return areaRectangle;
  375.  
  376. }
  377.  
  378. //AREA OF CIRCLE
  379. int areaOfCircle(){
  380.  
  381.     double radius;
  382.     long double pi = atan(1)*4;
  383.     system("cls");
  384.     cout << "\n\n Please, insert the radius of your circle:\n" << endl;
  385.     cout << "\11"; cin >> radius;
  386.     double areaCircle = pi*pow(radius, 2);
  387.     cout << "\n\11" << pi << " * " << radius << "^2 = " << setprecision(7) << areaCircle << endl;
  388.     cin.ignore();
  389.     getchar();
  390.  
  391.     return areaCircle;
  392.  
  393. }
  394.  
  395. //AREA OF TRIANGLE
  396. int areaOfTriangle(){
  397.  
  398.     double base;
  399.     double height;
  400.     system("cls");
  401.     cout << "\n\n Please, insert the base of your triangle:\n" << endl;
  402.     cout << "\11"; cin >> base;
  403.     cout << "\n\n Now, insert the vertical height of your triangle:\n" << endl;
  404.     cout << "\11"; cin >> height;
  405.     double areaTriangle = 0.5*base*height;
  406.     cout << "\n\11" << "0.5 * " << base << " * " << height << " = " << areaTriangle << endl;
  407.     cin.ignore();
  408.     getchar();
  409.  
  410.     return areaTriangle;
  411.  
  412. }
  413.  
  414. //CONVERTION OF DEGREES
  415. int convertionDegrees(){
  416.  
  417.     double celsius;
  418.     double fahrenheit;
  419.  
  420.     for (int choiceConvDeg; choiceConvDeg != 1 || 2;){
  421.         system("cls");
  422.         cout << "\n\n Please select what you'd like to convert:\n\n" << endl;
  423.         cout << "\11" << "1. Celsius to Fahrenheit\n\n" << "\11" << "2. Fahrenheit to Celsius\n\n\n\n\n\n\n\n\n\n\n 8. Back    9. Leave\n\n" << endl;
  424.         cin >> choiceConvDeg;
  425.  
  426.             switch(choiceConvDeg){
  427.             case 1:
  428.                 {
  429.                     system("cls");
  430.                     cout << "\n\n Please insert the amount of degree Celsius:\n\n" << endl;
  431.                     cout << "\11"; cin >> celsius;
  432.                     double fahrenheit = (celsius*1.8) + 32;
  433.                     cout << "\n\11" << celsius << "\370" << "C = " << fahrenheit << "\370" << "F" << endl;
  434.                     cin.ignore();
  435.                     getchar();
  436.                     break;
  437.                 }
  438.             case 2:
  439.                 {
  440.                     system("cls");
  441.                     cout << "\n\n Please insert the amount of degree Fahrenheit:\n\n" << endl;
  442.                     cout << "\11"; cin >> fahrenheit;
  443.                     double celsius = (fahrenheit - 32) / 1.8;
  444.                     cout << "\n\11" << fahrenheit << "\370C = " << celsius << "\370F" << endl;
  445.                     cin.ignore();
  446.                     getchar();
  447.                     break;
  448.  
  449.                 }
  450.             case 8:
  451.                 {
  452.                     converter();
  453.                     break;
  454.                 }
  455.             case 9:
  456.                 {
  457.                     exit(0);
  458.                 }
  459.             }
  460.     }
  461.  
  462. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement