Advertisement
UnlimitedSupply

Calculator

Jun 19th, 2022
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1.  /*
  2.     To calculate speed do Distance divided by time
  3.   */
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. bool
  9. ReDo ()
  10. {
  11.   string YesOrNo;
  12.   cout << "Want to go back to main?\n";
  13.   cin >> YesOrNo;
  14.   if (YesOrNo == "Y" || YesOrNo == "y" || YesOrNo == "Yes"
  15.       || YesOrNo == "yes")
  16.     {
  17.       return true;
  18.     }
  19.   else if (YesOrNo == "N" || YesOrNo == "n" || YesOrNo == "No"
  20.        || YesOrNo == "no")
  21.     {
  22.       return false;
  23.     }
  24.   else
  25.     {
  26.       ReDo ();
  27.     }
  28. }
  29.  
  30. bool
  31. USD ()
  32. {
  33.   string Type;
  34.   cout << "To?\n";
  35.   cout << "CAD (Canadian currency)\n" << "Pound (British currency)\n";
  36.   cin >> Type;
  37.   if (Type == "CAD" || Type == "cad")
  38.     {
  39.       int USDCASH;
  40.       int CADCASH;
  41.       cout << "Enter USD amount: ";
  42.       cin >> USDCASH;
  43.       CADCASH = (USDCASH / 1.33);
  44.       cout << CADCASH << " CAD\n";
  45.       return true;
  46.     }
  47.   else if (Type == "Pound" || Type == "pound")
  48.     {
  49.       int USDCASH;
  50.       int POUNDCASH;
  51.       cout << "Enter USD amount: ";
  52.       cin >> USDCASH;
  53.       POUNDCASH = (USDCASH * 0.77);
  54.       cout << POUNDCASH << " POUNDS\n";
  55.     }
  56.   else
  57.     {
  58.       return false;
  59.     }
  60. }
  61.  
  62. void
  63. Cash ()
  64. {
  65.   string Type;
  66.   cout << "Start from?\n";
  67.   cout << "USD\n" << "CAD (Canadian currency)\n" <<
  68.     "Pound (British currency)\n";
  69.   cin >> Type;
  70.   if (Type == "USD" || Type == "usd")
  71.     {
  72.       if (USD () == true)
  73.     {
  74.       cout << "Successful!\n";
  75.     }
  76.       else
  77.     {
  78.       cout << "UnSuccessful.\n";
  79.     }
  80.     }
  81. }
  82.  
  83. int
  84. main ()
  85. {
  86.   string Choice;
  87.   cout << "Which calculator?\n";
  88.   cout << "Speed\n" << "Cash\n" << "Normal calculator\n";
  89.   cin >> Choice;
  90.   if (Choice == "Cash" || Choice == "cash")
  91.     {
  92.       Cash ();
  93.     }
  94.     if (ReDo() == true) {
  95.         main();
  96.     } else {
  97.         cout << "Goodbye!\n";
  98.     }
  99. }
  100.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement