You are using a version without Ads of this website. Please, consider donating:

### ctt selection structure

SYNOPSIS

KBJ tourist agency Sdn. Bhd wants you to write an application program to calculate the total price for their customers for a package of vacation. The following table shows the price for three destinations (transportation and accommodation) offered by the agency:

Destination Transportation Accommodation
Pulau Redang Child RM15.00
Pulau Perhentian Child RM20.00
Pulau Kapas Child RM10.00

This agency company will give some discount to a group of customers with is:

a. 10% discount will be given for the group that has a least 5 adults.

b. 25% discount will be given for the group that has more than 5 persons (adults and children)

c. 30% discount will be given for the group that has at least 15 persons.

Your application program has to display the output using this following screen layout:

KBJ TOURIST CUSTOMER INFORMATION

Customerâ€™s name: XXXXXXXXXXXXX
Number of Children: XXXXX
Transportation: RMXXX.XX
Accommodation: RMXXX.XX
Total price: RMXXXX.XX

this is the code i got so far but it doesnt work..:(

#include <iostream.h>

int main ()
{
char customerName,code,A,B,C;
double rate,discount,totalPrice,a,c;
const double PriceA=95.00;
const double PriceB=100.00;
const double PriceC=120.00;

cin>>customerName;
cout<<"Enter The Number of Children:"<<endl;
cin>>childNum;
cout<<"*Package Destination Package Code*"<<endl;
cout<<"*Pulau Redang:A*"<<endl;
cout<<"*Pulau Perhentian:B*"<<endl;
cout<<"*Pulau Kapas:C*"<<endl;
cout<<"Choose Your Destination By Enter The Code:"<<endl;
cin>>code;

if (code=='A'||code=='a')
{
c=childNum*15.00;
rate=PriceA;
}

else if (code=='B'||code=='b')
{
c=childNum*20.00;
rate=PriceB;
}

else if (code=='C'||code=='c')
{
c=childNum*10.00;
rate=PriceC;
}
else
{
}

{
discount=0.1;
}

{
discount=0.25;
}

{
discount=0.3;
}

totalPrice=((a+c)-discount)+rate;

cout<<"\n====================================================="<<endl;
cout<<"\nCustomer's Name:"<<customerName<<endl;
cout<<"\nNumber of Children:"<<childNum<<endl;
cout<<"\nTransportation:"<<code<<endl;
cout<<"\nAccommodation:"<<rate<<endl;
cout<<"Total Price Is RM"<<totalPrice<<endl;
cout<<"\n====================================================="<<endl;

return 0;
}
 this is the code i got so far but it doesnt work

How does it fail?

Code tags would make the code more readable here.

 ``123`` ``````int a, b, c; ... a && b < c``````

That is a fail. It looks at 'a' first. If 'a' converts to false, then the result is false. Only if 'a' converts to true, the rest is evaluated, and the rest is 'b<c'. That is a boolean too. You probably did mean:
`(a+b) < c`

I don't understand discount "a". It seems to apply to only one very specific case.

Your equation for totalPrice is way of from how percentages operate.
help me..still cant get it right..:(
you must create new variable
ex.
int ab;

and than give value ab

and than, change parameter
if else(ab>=5)
{
.... .....
}
my problem now,it cannot run,when i try to run,it only can run to enter the name,then the rest are not...guysss,,help me..this is my first time to study this kind of subject,c++.
 ``123`` ``````char customerName; cout<<"Enter Your Name:"<>customerName;``````

Line 3 extracts only one non-whitespace character from stream -- the first letter that you write.
Even if you would have std::string customerName, you would still get only the first word. Study std::getline.
Yes, your code is wrong. I did point to one error in my previous post.

If you understand nothing and we correct your code, then you still understand nothing. That is not the purpose of your study, and it is complete waste of our time.
i think the souce code like this,,

#include <iostream.h>
#include <conio.h>

int main ()
{
const int max=100;
char customerName[max],code;
double rate,discount,totalPrice,a,c;
const double PriceA=95.00;
const double PriceB=100.00;
const double PriceC=120.00;

cin.getline(customerName,max);
cout<<"Enter The Number of Children:"<<endl;
cin>>childNum;
cout<<"*Package Destination Package Code*"<<endl;
cout<<"*Pulau Redang:A*"<<endl;
cout<<"*Pulau Perhentian:B*"<<endl;
cout<<"*Pulau Kapas:C*"<<endl;
cout<<"Choose Your Destination By Enter The Code:"<<endl;
cin>>code;

if (code=='A'||code=='a')
{
c=childNum*15.00;
rate=PriceA;
}

else if (code=='B'||code=='b')
{
c=childNum*20.00;
rate=PriceB;
}

else if (code=='C'||code=='c')
{
c=childNum*10.00;
rate=PriceC;
}
else
{
}

double tP=a+c+rate;

{
discount=0.1;
totalPrice=tP*discount;
}

else if (ac>5)
{
discount=0.25;
totalPrice=tP*discount;
}

else if (ac>=15)
{
discount=0.3;
totalPrice=tP*discount;
}
else
{
totalPrice=tP;
}

cout<<"\n====================================================="<<endl;
cout<<"\nCustomer's Name:"<<customerName<<endl;
cout<<"\nNumber of Children:"<<childNum<<endl;
cout<<"\nTransportation:"<<code<<endl;
cout<<"\nAccommodation:"<<rate<<endl;
cout<<"Total Price Is RM"<<totalPrice<<endl;
cout<<"\n====================================================="<<endl;

getch();
return 0;
}
Topic archived. No new replies allowed.

You are using a version without Ads of this website. Please, consider donating: