Question: I am working in c++ and this is the code I am working with, #include #include #include using namespace std; int main() { double gallons,

I am working in c++ and this is the code I am working with,

#include

#include

#include

using namespace std;

int main()

{

double gallons, charge = 0, total;

const int fee = 15;

int costUpTo6K = 2.35,

costUpTo20K = 3.75,

costOver20K = 6.00;

cout << "Enter the total number of gallons used, divided by 1000: ";

cin >> gallons;

if (gallons > 20){

charge = (gallons - 20) * costOver20K;

charge = charge + (14 * costUpTo20K);

charge = charge + (6 * costUpTo6K);

}

else if (gallons > 6 && gallons <= 20){

charge == (gallons - 6) * costUpTo20K;

charge == charge + (6 * costUpTo6K);

}

else (gallons <= costUpTo6K);

{

charge = gallons * costUpTo6k;

}

total = charge + fee;

cout << "You have used " << gallons << " thousand gallons of water." << endl;

cout << "Your total water bill is $" << setprecision(2) << fixed << fee;

return 0;

}

The error I have that pops up is this:

main.cpp: In function 'int main()': main.cpp:28:22: error: 'costUpTo6k' was not declared in this scope charge = gallons * costUpTo6k;

How do I fix this error and get the code to run? Thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!