*****************************************************
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;
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

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.

Edited 7 Years Ago by Ancient Dragon: n/a

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]

Edited 7 Years Ago by Ancient Dragon: n/a

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

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

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

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;
}
This question has already been answered. Start a new discussion instead.