Invalid Operands to Binary Expression

I have written this code as an assignment wherein some computations are done after the user enters a number of inputs, one of which is the day of the week. However my compiler (Xcode) does not accept my boolean expressions claiming "Invalid operands to binary expression". What can I do to fix this? I would appreciate any help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;
int main()
{
    std::string day;
    cout << "Please enter the day (Sa,Su,Mo,Tu,We,Th,Fr)" << endl;
    cin >> day;
    int day_value, time, minutes;
    double cost;
    if ((day == 'Su') || (day == 'su'))
        day_value = 1;
    if ((day == 'Sa') || (day == 'sa'))
        day_value = 2;
    if ((day == 'Mo') || (day == 'mo'))
        day_value = 3;
    if ((day == 'Tu') || (day == 'tu'))
        day_value = 4;
    if ((day == 'We') || (day == 'we'))
        day_value = 5;
    if ((day == 'Th') || (day == 'th'))
        day_value = 6;
    if ((day == 'Fr') || (day == 'fr'))
        day_value = 7;
    {cout<<"not a given day of the week"<<endl;
        goto start;}
    cout << "Enter the hour the call starts. (military time)" << endl;
    cin >> time;
    if (((time >= 8) && (time <= 18)) && ((day_value == 3) && (day_value == 4) || (day_value == 5) || (day_value == 6) || (day_value ==7)))
        cost = (minutes * 0.40);
    else if (((day_value == 3) && (day_value == 4) || (day_value == 5) || (day_value == 6) || (day_value == 7)) && ((time >= 18) && (time <= 24) && (time >= 0)))
        cost = (minutes * 0.25);
    else if ((day_value == 1) || (day_value == 2))
        cost = (minutes * 0.15);
    cout << "The cost of your phone call will be $" << cost << "." << endl;
    return 0;
}
closed account (o3hC5Di1)
Hi there,

Try using double quotes around your day names:

day=="Su"

Single quotes are for char literals, like 'c' or 'x'
Hope that helps. please do let us know if you require any further help.

All the best,
NwN
Topic archived. No new replies allowed.