*****************************************************
Write a program that will get some input from the user about a visit to an oil change service. The program will calculate the bill for the services requested.

Prompt the user to input whether or not they want each of the services. You can assume the input will be a character that is either a 'y' or an 'n'. Print out the total of the bill. Write this as efficiently as you can, using as few comparisons and if statements as possible. And NO, do not use a "switch" statement.
******************************************************

This is what I have so far... it dosnt compile :(

#include<iostream>
#include<cmath>

using namespace std;

int main ()
{
    int oil_change = 25;
    int air_filter = 15;
    int chassis_lube = 10;
    int vac_and_glass = 20;
    int total = 0;
    char yes;
    char no;
    char yn = yes || no;


    cout << endl;
    cout << "              Welcome to the car service shop!              " << endl;
    cout << endl;
    cout << "We have many service options to chose from!" << endl;
    cout << endl;
    cout << "Oil change .................................... $25" << endl;
    cout << "Air filter replacement ........................ $15" << endl;
    cout << "Chassis Lubrication ........................... $10" << endl;
    cout << "Vacuum floors and clean windows ............... $20" << endl;
    cout << endl;
    cout << "Please input your anwsers as y for yes and n for no" << endl;
    cout << endl;
    cout << "Would you like the basic oil change?";
    cin >> (yn);
    {   
        if (yn = yes)
            (total = total + oil_change);
        else if (yn = no)
            (total = total + 0);

    }
    cout << endl;
    cout << "Would you like an Air Filter replacement?";
    cin >> (yn);
    {   
        if (yn = yes)
            (total = total + air_filter);
        else if (yn = no)
            (total = total +0);
    }
    cout << endl;
    cout << "Would you like a Chassis Lubrication?";
    cin >> (yn);
    {   
        if (yn = yes)
            (total = total + chassis_lube);
        else if (yn = no)
            (total = total + 0);
    }
    cout << endl;
    cout << "And finally would you like the floors vacuumed and windows cleaned?";
    cin >> (yn);
    {   
        if (yn = yes)
            (total = total + vac_and_glass);
        else if (yn = no)
            (total = total + 0);
    }

    cout << endl;
    cout << "           *** Your final total cost is $"<< total << " ***      " << endl;
    cout << endl;
    cout << "Thank you for your business!" << endl;
return 0;
}

Edit your post and use code tags to make it easier to tell you what is wrong with it.

For starters, you do not need the two variables called yes and no. What you have to do is check for 'y' or 'n' if( yn == 'y') And remember: = is the assignment operator, == is the comparison operator. Don't confuse the two.

Im really new to programming and am struggling big time in my comp sci class....

Lol are code tags just like an explanation of what im doing?

but I wanna say thanks for your input, ill see if I can finish it up with what you said

code tags: look in the Quick Reply box and you will see an explanation of them in the watermarks (light grey text). If you can not see them, then just put [code] at the beginning of the code and [/code] at the end, like this:

[code]

// your program goes here

[/code]

when I took the two (yes) and (no) variables out I get,

error C2065: 'yes' : undeclared identifier
error C2065: 'no' : undeclared identifier

Well, you have to change the rest of your code too so that it uses 'y' and 'n' instead of yes and no.

did that but I think its referring to the declarations at the top

if you mean char yes; then just delete them.

QUOTE=UKmason;1024892]*****************************************************
Try this

#include<iostream>

using namespace std;

int main ()
{
	int oil_change = 25;
	int air_filter = 15;
	int chassis_lube = 10;
	int vac_and_glass = 20;
	int total = 0;
                 char answer;
	
	
	cout << endl;
	cout << "              Welcome to the car service shop!              " << endl;
	cout << endl;
	cout << "We have many service options to chose from!" << endl;
	cout << endl;
	cout << "Oil change .................................... $25" << endl;
	cout << "Air filter replacement ........................ $15" << endl;
	cout << "Chassis Lubrication ........................... $10" << endl;
	cout << "Vacuum floors and clean windows ............... $20" << endl;
	cout << endl;
	cout << "Please input your anwsers as y for yes and n for no" << endl;
	cout << endl;
	cout << "Would you like the basic oil change?";
	cin >> answer;
	
	if (answer == 'y')
		total = total + oil_change;
	else if (answer == 'n')
		total = total + 0;
	
	
	cout << endl;
	cout << "Would you like an Air Filter replacement?";
	cin >> answer;
	
	if (answer == 'y')
		total = total + air_filter;
	else if (answer == 'n')
		total = total +0;
	
	cout << endl;
	cout << "Would you like a Chassis Lubrication?";
	cin >> answer;
		
	if (answer == 'y')
		total = total + chassis_lube;
	else if (answer == 'n')
		total = total + 0;
	
	cout << endl;
	cout << "And finally would you like the floors vacuumed and windows cleaned?";
	cin >> answer;
	
	if (answer == 'y')
		total = total + vac_and_glass;
	else if (answer == 'n')
		total = total + 0;
	

	cout << endl;
	cout << "           *** Your final total cost is $"<< total << " ***      " << endl;
	cout << endl;
	cout << "Thank you for your business!" << endl;
return 0;
}
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.