contacttonipun 0 Newbie Poster

I am not able to solve problem number 25 mentioned in the attachment. The problem is related to questions 23 and 24, which I have solved. Their code is given below. Can anyone help me with problem 25? Just so you know, since I am a beginner, I am only allowed to use if statements, switch, and menus and not loops or any other advanced concepts. I'm just a newbie to programming languages, so any help is appreciated. :)

#include <iostream>
using namespace std;

int main ()
{
    char package;
    double hours, amount, save_A1, save_A2, save_B;

    cout << "Enter your monthly internet package code (A, B, or C): ";
    cin >> package;
    if (package == 'A' || package == 'B' || package == 'C' || package == 'a' || package == 'b' || package == 'c')
    {
    cout << "\nEnter the number of hours used monthly: ";
    cin >> hours;
    if (hours <=744 && hours >=0)

        switch (package)
    {

    case 'a':
    case 'A': if (hours <= 10)
                amount = 9.95;
              else
                amount = 9.95 + (hours-10) * 2.0;
        cout << "\nYour monthly bill is: " << amount << endl;
        if (amount > 14.95) 
        {
            if (hours > 20)
            save_A1 = amount - (14.95 + (hours-20) * 1.0);
            else
                save_A1 = amount -14.95;
            cout << "\nYour savings if you would have chosen Package B would have been: " << save_A1 << endl;
            if (amount > 19.95)
            {
            save_A2 = amount - 19.95;
            cout << "\nYour savings if you would have chosen Package C would have been: " << save_A2 << endl;
            }
        }
            break;

    case 'b':
    case 'B': if (hours <= 20)
                amount = 14.95;
              else
                amount = 14.95 + (hours-20) * 1.0;
        cout << "\nYour monthly bill is: " << amount << endl;
        if (amount > 19.95)
        {
            save_B = amount - 19.95;
            cout << "\nYour savings if you would have chosen Package B would have been: " << save_B << endl;
        }
            break;

    case 'c':
    case 'C': amount = 19.95;
        cout << "\nYour monthly bill is: " << amount << endl;
        break;

    }

    else

    {
        cout << "\nThe number of hours you have entered is not correct.\n";
    }
    }

    else
    cout << "\nPlease enter correct package code.\n" << endl;



    cout << endl;

    return 0;

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.