/* 10/24/25
 This program helps you calculate your monthly mobile phone bill based on your
  subscription package and the number of minutes you have used. Additionally, it will
  show you how much money you could save if you chose a different package.
 */
 
#include <iostream>
#include <iomanip>
 
using namespace std;
 
int main(){
    //Declares and initialized constants for package A
    const float packAFee = 39.99;
    const int packAMin = 450;
    const float packAMinFee = 0.45;
 
    //Declares and initialized constants for package B
    const float packBFee = 59.99;
    const int packBMin = 900;
    const float packBMinFee = 0.40;
 
    //Declares and initialized constants for package C
    const float packCFee = 69.99;
 
    //Declares user variables
    int packageType;
    float userFee;
    int userMin;
    int numMin;
    float amountDue;
 
    //Prompts user to enter their package type
    cout << "Select a subscription package:\n1. Package A\n2. Package B"
         << "\n3. Package C\n4. Quit" << endl;
 
    cin >> packageType;
 
    //Decides whether user entered a valid package type
    switch(packageType){
        case(1):
            userFee = packAFee;
            break;
        case(2):
            userFee = packBFee;
            break;
        case(3):
            userFee = packCFee;
            break;
        case(4):
            return 0;
        default:
            cout << "The valid choices are 1 through 4. Run the"
                 << "\nprogram again and select one of those.";
            return 0;
    }
 
    //Prompts user for the number of minutes they used
    cout << "How many minutes were used? ";
    cin >> numMin;
 
    int tempMin = numMin; //creates a copy of numMin
 
    //Calculates the amount due based on package type
    if(packageType == 1){
        tempMin -= packAMin;
        if(tempMin < 0)
            tempMin = 0;
        amountDue = packAFee + tempMin * packAMinFee;
    }
    else if(packageType == 2){
        tempMin -= packBMin;
        if(tempMin < 0)
            tempMin = 0;
        amountDue = packBFee + tempMin * packBMinFee;
    }
    else
        amountDue = packCFee;
 
    //Outputs the amount due to the user
    cout << "The total amount due is $" << amountDue << endl;
 
    //Declares temporary variables to find potential savings
    char tempPack1, tempPack2;
    float tempDue1, tempDue2;
 
    //Decides which packages need to be compared
    switch(packageType){
        case(1):
            tempPack1 = 'B';
            tempPack2 = 'C';
            break;
        case(2):
            tempPack1 = 'A';
            tempPack2 = 'C';
            break;
        case(3):
            tempPack1 = 'A';
            tempPack2 = 'B';
            break;
    }
 
    //resets tempMin to its original value
    tempMin = numMin;
 
    //Calculates the amount due based on the package
    if(tempPack1 == 'A'){
        tempMin -= packAMin;
        if(tempMin < 0)
            tempMin = 0;
        tempDue1 = packAFee + tempMin * packAMinFee;
    }
    else if(tempPack1 == 'B'){
        tempMin -= packBMin;
        if(tempMin < 0)
            tempMin = 0;
        tempDue1 = packBFee + tempMin * packBMinFee;
    }
    else
        tempDue1 = packCFee;
 
    //resets tempMin to its original value
    tempMin = numMin;
 
    //Calculates the amount due based on the package
    if(tempPack2 == 'A'){
        tempMin -= packAMin;
        if(tempMin < 0)
            tempMin = 0;
        tempDue2 = packAFee + tempMin * packAMinFee;
    }
    else if(tempPack2 == 'B'){
        tempMin -= packBMin;
        if(tempMin < 0)
            tempMin = 0;
        tempDue2 = packBFee + tempMin * packBMinFee;
    }
    else
        tempDue2 = packCFee;
 
    //Decides whether there are savings and outputs the amount for each package
    cout << "Savings with Package " << tempPack1 << ": ";
    cout << fixed << setprecision(2);
 
    if(tempDue1 < amountDue)
        cout << "$" << amountDue - tempDue1 << endl;
    else
        cout << "No Saving!" << endl;
 
    cout << "Savings with Package " << tempPack2 << ": ";
 
    if(tempDue2 < amountDue)
        cout << "$" << amountDue - tempDue2 << endl;
    else
        cout << "No Saving!" << endl;
}