63 103
Assignments Done
99%
Successfully Done
In July 2018

Answer to Question #29425 in C++ for kaka

Question #29425
Write a program for calculation of the total price of package of vacation. There are 3 destination : New Zealand, Korea, Japan. The rate of accommodation for New Zealand is 80 per day, Korea is 100 per day, Japan is 110 per day. For New Zealand, child will be charge 10,adult 20, for Korea child will be charge 20,adult 30, for Japan child will be charge 30,adult 40. Write c++ program that ask user to enter name, number of child,number of adult,accommodation and total price.
Expert's answer
#include <iostream>
#include <string>
using namespace std;

enum { //constans
NZ_Accomm= 80,
K_Accomm = 100,
J_Accomm = 110,

NZ_Child= 10,
NZ_Adult= 20,

K_Child = 20,
K_Adult = 30,

J_Child = 30,
J_Adult = 40
};

int main() {
cout<< "enter name of vacation: ";
stringname;
cin>> name;
cout<< "enter number of child: ";
intchildren;
cin>> children;
cout<< "enter number of adult: ";
intadult;
cin>> adult;
cout<< "enter number of accommodation days: ";
intdays;
cin>> days;
inttotal_price = 0;
boolok_name = true;
if(name.compare("New Zealand") == 0) { //new zealand
total_price= children*NZ_Child + adult*NZ_Adult + days*NZ_Accomm;
}else if (name.compare("Korea") == 0) {
total_price= children*K_Child + adult*K_Adult + days*K_Accomm;
}else if (name.compare("Japan") == 0) {
total_price= children*J_Child + adult*J_Adult + days*J_Accomm;
}else {
ok_name= false;
}
if(ok_name) {
cout<< "Total price: " << total_price << endl;
}else {
cout<< "wrong name
";
}
return0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions