I have no idea what I'm doing wrong, any help is very much appreciated!

#include <iostream>
#include <string>
using namespace std;

int main()

    int hours, mins, minutes;
    char day1, day2, choice;

        cout << "Enter the day of call (Mo/Tu/We/Th/Fr/Sa/Su): " << endl;
        day1 = getchar();
        day2 = getchar();

        cout << "Enter time of call hour (1:30 PM Enter 13)";
        cin >> hours;

        cout << "Enter min of hour (Enter 30 for 1:30 PM)";
        cin >> mins;

        cout << "Enter call duration in minutes" << endl;
        cin >> minutes;


        if 
        {

            (((day1 == 'S' || day1 == 's') &&
            (day2 == 'a' || day2 == 'A')) ||
            (((day1 == 'S' || day1 == 's') &&
            (day2 == 'u' || day2 == 'U'))))


            cout << "Call charges are: $ " << (.15* minutes);
        }
        else if


    {

        (((day1 == 'M' || day1 == 'm') &&
        (day2 == 'o' || day2 == 'O')) ||
        (((day1 == 'T' || day1 == 't') &&
        (day2 == 'u' || day2 == 'U')) ||
        (((day1 == 'W' || day1 == 'w') &&
        (day2 == 'e' || day2 == 'E')) ||
        (((day1 == 'T' || day1 == 't') &&
        (day2 == 'h' || day2 == 'H')) ||
        (((day1 == 'F' || day1 == 'f') &&
        (day2 == 'r' || day2 == 'R'))))

    }

        else if 
            {   (hours >= 8 && hours < 18);


                cout << "Call charges are: $ " << (.40 * minutes);
            }

            else if
            {
                cout << "Call charges are : $" << (.25 * minutes);

            }

             else 

              {
                 cout << "You enter wrong values";

    }



while
{
    (choice == 'y' || choice == 'Y')

    cout << "\n To repeat calculations for different values either press 'Y' or 'y' " << endl;
    cin >> choice;
}



 system("Pause");

}

Recommended Answers

All 4 Replies

What your program does exactly?

You are using { } to contain your logical conditions, when you should be using ( )

Your second block looks like it should have the time of day test as an if, not else if.

You have a loop at the end to keep doing the calculation, but no way of getting back to the top. Perhaps a do...while construct is called for.

You are also using a C getchar() call with no C/C++ header <cstdio> to match.

But since ... coding in C++ ... use cin.get() instead.

Why not use toupper or tolower in your input, instead of doing (day1 == 'S' || day1 == 's')?

commented: good advice +4
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.