Help! I can't seem to see my error...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cuthien
    New Member
    • Sep 2008
    • 1

    #1

    Help! I can't seem to see my error...

    I'm using visual studio, and i'm trying to find my error. i you could please point out what I'm doing wrong, I would appreciate it. Right now I keep getting error error C2064.

    char name;
    double day, night, regular, premium, totalR;
    cout << "Enter your name" << "\nEnter the number of minutes used from 6AM - 6PM" << "Enter the number of minutes used from 6PM - 6AM";
    cin >> name >> day >> night;
    totalR = day + night;

    if (totalR > 50){
    regular = 10 + .20((totalR) - 50);
    }
    else {
    regular = 10;
    }

    if (day > 75) {
    if (day > 75 && night > 100) {
    premium = 25 + .1(day - 75) + .05(night - 100);
    }
    else {
    premium = 25 + .1(day - 75);
    }
    }
    else {
    if (night > 100) {
    premium = 25 + .05(night - 100);
    }
    else {
    premium = 25;
    }
    }

    cout << setiosflags(ios ::fixed|ios::sh owpoint) << setprecision(2) ;
    cout << "Regular plan cost" << regular << endl;
    cout << "Premium plan cost" << premium << endl;

    return 0;
    }
  • boxfish
    Recognized Expert Contributor
    • Mar 2008
    • 469

    #2
    Just in case it's actually not there, you need
    Code:
    #include <iostream>
    #include <iomanip>
    
    using namespace std;
    
    int main() {
    at the beginning of your program, but you probably actually have it there and just didn't post it. Your problem is on lines of code like these:
    Code:
    if (day > 75 && night > 100) {
    premium = 25 + .1(day - 75) + .05(night - 100);
    }
    else {
    premium = 25 + .1(day - 75);
    }
    In order to do multiplication in C++, you always have to use the * operator. Parentheses will not do. Your compiler thinks you're trying to call a function. Change these to:
    Code:
    if (day > 75 && night > 100) {
    premium = 25 + .1 * (day - 75) + .05 * (night - 100);
    }
    else {
    premium = 25 + .1 * (day - 75);
    }
    Hope this helps.

    Comment

    Working...