Advertisement
Guest User

Longest Code yet.

a guest
Jul 18th, 2016
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.97 KB | None | 0 0
  1. /*
  2.     MSP v1.0
  3.     Created by Julio Milian
  4.     July 17. 2016
  5.  
  6.     Program will calculate the amount due
  7.     after a month of cellular usage.
  8. */
  9.  
  10. #include <iostream>
  11. #include <iomanip>
  12. using namespace std;
  13.  
  14. int main() {
  15.  
  16.     double aPrice = 39.99;
  17.     double bPrice = 59.99;
  18.     double cPrice = 69.99;
  19.     double mins = 0.0;
  20.     double aMins = 0.0;
  21.     double bMins = 0.0;
  22.     double total = 0.0;
  23.     double atotal = 0.0;
  24.     double btotal = 0.0;
  25.     char input;
  26.  
  27.     cout << "Which monthly package do you currently have? ";
  28.     cin >> input;
  29.     cout << "How many minutes did you use within the month? ";
  30.     cin >> mins;
  31.     // switch case start -------------------------------------------------------------------------
  32.     switch (input)
  33.     {
  34.     case 'A':
  35.     case 'a':
  36.         cout << "\nYou have chosen plan A!\n";
  37.         total = total + aPrice;
  38.         cout << "\nMonthly charge is $" << total << endl;
  39.         aMins = 450 - mins;
  40.  
  41.         if (aMins > 0)
  42.             cout << "You still had minutes left over in the month!" << endl;
  43.         else {
  44.             aMins = aMins * -1;
  45.             aMins = aMins * 0.45;
  46.             total = total + aMins;
  47.         }
  48.         cout << "Your total due balance for this month is $" << total << "\n\n";
  49.  
  50.         //check if plan b is cheaper
  51.         btotal = bPrice;
  52.         mins = 900 - mins;
  53.         if (mins < 0) {
  54.             mins = mins * -1;
  55.             mins = mins * 0.40;
  56.             btotal = btotal + mins;
  57.         }
  58.  
  59.         if (btotal < total && btotal < cPrice) {
  60.             cout << "Plan B would have been cheaper for the amount of minutes you used.\n";
  61.             cout << "The total using plan B would have been $" << btotal << endl;
  62.             btotal = total - btotal;
  63.             cout << "You would have saved $" << btotal << "\n\n";
  64.         }
  65.         else
  66.             if (btotal > cPrice) {
  67.                 cout << "Plan C would have been cheaper!\n";
  68.                 total = btotal - total;
  69.                 total = total * -1;
  70.                 cout << "You would have saved $" << total << endl;
  71.                 cout << "Your monthly charge would have been $" << cPrice << endl;
  72.             }
  73.             else
  74.                 cout << "Plan A is the cheapest with the minutes you used!\n";
  75.         break;
  76.  
  77.     //CASE B - PLAN B --------------------------------------------------------------------------
  78.  
  79.     case 'B':
  80.     case 'b':
  81.         aMins = mins;
  82.         cout << "You have chosen plan B!\n";
  83.         total = total + bPrice;
  84.         cout << "\nMonthly charge is " << total << endl;
  85.         mins = 900 - mins;
  86.         if (mins > 0)
  87.             cout << "You still had minutes left over in the month!" << endl;
  88.         else {
  89.             mins = mins * -1;
  90.             mins = mins * 0.40;
  91.             total = total + mins;
  92.         }
  93.         cout << "Your total due balance for this month is " << total << endl;
  94.  
  95.         //check if plan a is cheaper
  96.         atotal = aPrice;
  97.         aMins = 450 - aMins;
  98.         if (aMins < 0) {
  99.             aMins = aMins * -0.45;
  100.             atotal = atotal + aMins;
  101.         }
  102.         if (atotal < total && atotal < cPrice) {
  103.             cout << "\nPlan A would have been cheaper this month!\n";
  104.             atotal = total - atotal;
  105.             cout << "It would have saved you $" << atotal << endl;
  106.             cout << "Your total for Plan A would have been $" << atotal << endl;
  107.         }
  108.  
  109.         //check if plan c is cheaper
  110.         if (total > cPrice){
  111.             cout << "\nPlan C would have been cheaper!\n";
  112.             cPrice = total - cPrice;
  113.             cout << "You would have saved $" << cPrice << endl;
  114.         }
  115.         break;
  116.  
  117.         //CASE C - PLAN C --------------------------------------------------------------------------
  118.  
  119.     case 'C':
  120.     case 'c':
  121.         total = cPrice;
  122.         cout << "\nMonthly charge is " << total << endl;
  123.         cout << "Your total due balance for this month is " << total << endl;
  124.         //check if plan a is cheaper
  125.         if (mins <= 494) {
  126.             aMins = 450 - mins;
  127.             aMins = aMins * -0.45;
  128.             atotal = 49.99 + aMins;
  129.             atotal = total - atotal;
  130.             cout << "\nPlan A would have been cheaper.\n";
  131.             cout << "You would have saved $" << atotal << endl;
  132.         }
  133.         //check if plan b was cheaper
  134.         if (mins <= 924) {
  135.             bMins = 900 - mins;
  136.             bMins = bMins * -0.4;
  137.             btotal = 59.99 + bMins;
  138.             btotal = total - btotal;
  139.             cout << "\nPlan B would have been cheaper.\n";
  140.             cout << "You would have saved $" << btotal << endl;
  141.         }
  142.         break;
  143.     default:
  144.         cout << "\nPlease select A, B, or C.\n\n";
  145.         break;
  146.     }//end switch
  147.     return 0;
  148. }//end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement