Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Need some help with my c++ code

Name: hopless new guy 2008-02-22 22:47

for some reason it wont give the error message if the hours are over the monthly hours



#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstring>
using namespace std;

int main()
{
    char pack;
    double bill, hour;
    int max_hours;
    const int SIZE=50;
    char month[SIZE];


//format bill
    cout << showpoint<<fixed<<setprecision(2);


    // menus
    cout << "Please select one of the three subscription packages."<<endl;
    cout << "Avaliable Packages: a, b, c"<<endl;
    cout << "Package: ";
    cin >> pack;
    cout <<endl;

    cout << "How many hours of access are used? :";
    cin >> hour;
    cout << "What is the month?: ";
    cin >> month;
   

       

//max hours per month
    if (strcmp("january", month))
        {
        max_hours = 744;
        }
        else if (strcmp("february", month))
        {
        max_hours = 672;
        }
        else if (strcmp("march", month))
        {
        max_hours = 744;
        }
        else if (strcmp("april", month))
        {
        max_hours = 720;
        }
        else if (strcmp("may", month))
        {
        max_hours = 744;
        }
        else if (strcmp("june", month))
        {
        max_hours = 720;
        }
        else if (strcmp("july", month))
        {
        max_hours = 744;
        }
        else if (strcmp("august", month))
        {
        max_hours = 744;
        }
        else if (strcmp("september", month))
        {
        max_hours = 720;
        }
        else if (strcmp("october", month))
        {
        max_hours = 744;
        }
        else if (strcmp("november", month))
        {
        max_hours = 720;
        }
        else if (strcmp("december", month))
        {
        max_hours = 744;
        }

    else
    {
        cout << " Not a valit input. Check the spelling and case."<<endl;
    }


//calculation and bill output
    switch (pack)
    {
        case 'a':
            if (hour > max_hours)
            cout <<"Can not exceed montly hours"<<endl;

            else if (hour >= 10)
            {
                bill = 9.95 + (2.00*(hour - 10));
                cout << "The bill for "<<month<<" is: $"<<bill<<endl;
            }
            else
            {
                cout << "The bill for "<<month<<" is $9.95"<<endl;
            }
            break;

        case 'b':
            if (hour > max_hours)
            cout <<"Hours can not exceed monthly hours"<<endl;

            else if (hour >= 20)
            {
                bill = 14.95 + (1.00*(hour - 20));
                cout << "The bill for "<<month<<" is: $"<<bill<<endl;
            }
            else
            {
                cout << "The bill for "<<month<<" is $9.95"<<endl;
            }
            break;

        case 'c':
                cout << "The bill for "<<month<<" is $19.99"<<endl;
    }






    return 0;
}

Name: Anonymous 2008-02-23 21:27

>>17

Aw shit, I just failed hard.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List