# include <iostream>
using namespace std;
int main()
{
int tot,hc=50,cp=500,ho=150,hs=250,x=0,y;
if (hc=y);{
cout<<"Did the customer avail the following services:(Y/N):";cin>>y;
cout<<"\n";
cout<<"HairCut P 50.00: ";cout<<endl;cin>>hc;
tot=hc+x;cout<<tot;
} else
(hc=0); {
cout<< "Total";cin>>hc;cout<<"\n";}
if (cp=y);{
cout<< "Did the customer avail the following services: (Y/N): ";cin>>y;
cout<<"\n";{cout<<"Cellophane P 500: ";cout<<endl;cin>>cp;
tot=cp+x;cout<<tot; }
else{
(cp=0);
cout<< "Total";cin>>cp;cout<<"\n";}
if (ho=y);{
cout<< "Did the customer avail the following services: (Y/N): ";
cout<<"\n";cout<<"\n";
cout<<"HotOil P 150.00: ";cout<<endl;cin>>ho;
tot=ho+x;cout<<tot;
}
else{
(ho=0);
cout<< "Total";cin>>ho;cout<<"\n";}
{
if (hs=y);{
cout<< "Did the customer avail the following services: (Y/N): ";cout<<"\n";
cout<<"\n";cout<<"HairSpa P 250.00: ";cout<<endl;}cin>>hs;
tot=hs+x;cout<<tot;
}
else{
(hs=0);
cout<< "Total";cin>>hs;cout<<"\n";}
}
return 0;
}
This program i made i havent finish yet because I rec. lot of errors , i was trying to calculate the total services rendered, if the answer is yes the total would add up to the amount of total if no the total would leave leave no value and it will sum up the total...really getting a hard time on this! can someone give me a tip on proper coding of variables, identifiers and logic to this programming...thanks in advance
# include <iostream>
usingnamespace std;
constint hc=50; // price for hair cut
constint cp=500; // price for cellophane
constint ho=150; // price for hot oil
constint hs=250; // price for hair spa
int main()
{
int tot=0;
char y;
cout<<"Did the customer avail the following services:(Y/N):" << endl;
cout<<"HairCut P 50.00: ";
cin >> y;
if (y=='Y' || y=='y') tot=hc;
cout << "total: " << tot << endl << endl;
cout<< "Did the customer avail the following services: (Y/N): " << endl;
cout<<"Cellophane P 500: ";
cin >> y;
if (y=='Y' || y=='y') tot+=cp;
cout << "total: " << tot << endl << endl;
cout<< "Did the customer avail the following services: (Y/N): " << endl;
cout<<"HotOil P 150.00: ";
cin >> y;
if (y=='Y' || y=='y') tot+=ho;
cout << "total: " << tot << endl << endl;
cout<< "Did the customer avail the following services: (Y/N): " << endl;
cout<<"HairSpa P 250.00: ";
cin >> y;
if (y=='Y' || y=='y') tot+=hs;
cout << "total: " << tot << endl << endl;
return 0;
}
I moved your prices for services up into const values because that makes more sense than using them as regular variables for calculating the total. I initialized total to the value of 0 to begin with so that it doesn't have garbage data before you start using it. I changed the variable y to the type char so that you could check it for user input of a character using cin.
In this program, all you do is enter 'Y' or 'y' to the prompt to tell if the customer got that service, and if so, the price of the service will be added to the total. I hope that's what you wanted.
thank you very much it helps a lot but i was trying to input a membership either gold 10% discount and silver 5% discount in the total amout, so I was supposed to display the amount of discount and the new total for the discounted amount,.
include <iostream>
using namespace std;
const int hc=50; // price for hair cut
const int cp=500; // price for cellophane
const int ho=150; // price for hot oil
const int hs=250; // price for hair spa
const int gold=10% // Discount for total amout
const int silver=5% // Discount for total amount
int main()
{
int tot=0;int dis = 0;int nt=0;
char y,mem;
cout<<"Did the customer avail the following services:(Y/N):" << endl;
cout<<"HairCut P 50.00: ";
cin >> y;cin>>mem;
if (y=='Y' || y=='y') tot=hc;
cout << "total: " << tot << endl << endl;
cout<<"Cellophane P 500: ";
cin >> y;
if (y=='Y' || y=='y') tot+=cp;
cout << "total: " << tot << endl << endl;
cout<<"HotOil P 150.00: ";
cin >> y;
if (y=='Y' || y=='y') tot+=ho;
cout << "total: " << tot << endl << endl;
cout<<"HairSpa P 250.00: ";
cin >> y;
if (y=='Y' || y=='y') tot+=hs;
cout << "total: " << tot << endl << endl;}
I still didn't get much logic, I was trying to solve this for a day
still can't get it, can you help me with an idea to learn this as fast as possible for a very newbie like me, is it reading in more examples, thanks a lot!
Well, you can't define int(egers) as a %...you would have to use a double or a float. Also remember that variables are case-sensitive (i.e. NT doesn't mean nt).