Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

give to explain and pesdue code plz.. Note that this problem requires the implem

ID: 3797628 • Letter: G

Question

give to explain and pesdue code plz..

Note that this problem requires the implementation of a small menu system (see Section 4.10) as well as input validation (see Section 4.11). The menu system can be implemented at our current level with an "if-else-if" ladder or by a switch statement. The input validation can be done with standard "if statements. Program 4-18 is an excellent model for the solution to this problem, at least as far as the basic structure is concerned. Make sure you understand exactly what is to be calculated in each "package." For example, if Package A is chosen and the user wants 650 minutes, how should the monthly bill be calculated exactly? I suggest you work out those equations in pseudo-code before you begin writing the program. Also, take note of the input validation requirements at the end of the problem (in italics). They specify that only 'A', 'B', or 'C' is allowed as the input for the package. Have your program accept either upper or lower case letters for the package choice (e.g., either 'A' or 'a' will choose package 'A'). Anything outside of the range A 'C' or the range a c' should be considered an error. Also, note that the problem asks the user to enter how many minutes were used even if Package "C" is chosen. This may seem redundant in the case of Package "C," but it will be useful in the following modification. Consequently, your program should ask both of those questions up

Explanation / Answer

/*
pseudo code:

Input package
input minutes

calculate the amount due
check if amount is the best package
else print the best package

end
*/

// C++ code
#include <iostream>
#include <fstream>
#include <cctype>
#include <cstring>
#include <stdlib.h>     /* srand, rand */
#include <iomanip>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <string.h>

#define PI 3.14159
#define SLICE_AREA 14.125
using namespace std;

double min(double a, double b, double c)
{
    if(a < b && a < c)
      return a;
    else if(b < a && b < c)
      return b;
    else
      return c;
}

int main()
{
      char package;
      int minutes;
      double package1, package2, package3;
      double amountDue = 0;

      // input validaton for package
      while(true)
      {
          cout << "Enter the package: ";
          cin >> package;

          if(package == 'A' || package == 'a' || package == 'B' || package == 'b' || package == 'C' || package == 'c')
            break;

          else
            cout << "Packages are A, B and C only ";
      }

  
      while(true)
      {
          cout << "Enter the minutes used: ";
          cin >> minutes;

          if(minutes < 0)
            cout << "Minues should be positive ";

          else
            break;
      }

      if(package == 'A' || package == 'a')
      {
          amountDue = 39.99;

          if(minutes >= 450)
            amountDue = amountDue + (minutes-450)*0.45;
      }

      else if(package == 'B' || package == 'b')
      {
          amountDue = 59.99;

          if(minutes >= 900)
            amountDue = amountDue + (minutes-900)*0.40;
      }

      else if(package == 'C' || package == 'c')
      {
          amountDue = 69.99;
      }

      if(minutes > 450)
        package1 = 39.99 + (minutes-450)*0.45;
      else
        package1 = 39.99;

      if(minutes > 900)
        package2 = 59.99 + (minutes-900)*0.40;
      else
        package2 = 59.99;

      package3 = 69.99;

      double minimum = min(package1,package2,package3);

      cout << " Amount due: " << amountDue << endl;

      if(minimum == amountDue)
        cout << "You selected the best package, Congratulation! ";
      else
        cout << "You had a better option available " << "Best rate: " << minimum << endl;


    return 0;
}

/*
output:

Enter the package: v
Packages are A, B and C only
Enter the package: C
Enter the minutes used: 500

Amount due: 69.99
You had a better option available
Best rate: 59.99


Enter the package: b
Enter the minutes used: 800

Amount due: 59.99
You selected the best package, Congratulation!


*/