107 449
Assignments Done
96.1%
Successfully Done
In May 2023

# Answer to Question #12881 in C++ for shalennee

Question #12881
You are required to calculate and display the fee for a bus passenger. The fee for an adult is RM15.00 and a child is RM8.00 each. However, an adult 50 years old and above will get 10% discount from the adult fee. The bus provides 20 seats for adults, 7 seats for adult above 50 years old and 13 seats for children.
1
2012-08-10T09:26:52-0400
#include <iostream>
using namespace std;

int main (){
int allOfTickets = 40;
int mark = 0;
do {
&
& if (mark == 1) {
& if (child == 0) cout<<"Sorry it's out of tickets\n";
& else {
& cout<< "RM8.00 ticket for child\n";
& child--; allOfTickets--;
& }
&
& } else if (mark == 2) {
& if (adult == 0) cout<<"Sorry it's out of tickets\n";
& else {
& cout<< "RM15.00 ticket for adult\n";
& }
& } else if (mark == 3) {
& if (adultAbove == 0) cout<<"Sorry it's out of tickets\n";
& else{
& cout<< "RM13.50 ticket for adult above 50 year\n";
& }
& }
& cout<<"If you need ticket for child ENTER - 1\nIf you need ticket for adult ENTER - 2\nIf you need ticket for adult above 50 year ENTER - 3\nExit ENTER - Ctrl+Z\n";
&
} while (allOfTickets > 0 && cin>>mark);

return 0;
}

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!