By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

Program to calculate the cost of travelling to different zones

P: 24
Can someone please, please help me in finding the slotuion of the following problem:

The cost of one-day travel cards for adult customers on the metro system is based on which zones they cover and is summarised in the following table:

Zone Cost
1 1.70
1 & 2 3.70
1, 2 & 3 4.70
1, 2, 3 & 4 6.00
1, 2, 3, 4 & 5 6.70
1, 2, 3, 4, 5 & 6 9.10

Passengers who are under 16 years of age travel for half price.

Write a C++ program which allows the user to enter the number of the farthest zone they wish to travel to and their age and calculates and displays the price of the appropriate travel card.

Use a loop parogram so the the above calculation can be done over and over again allowing the user to enter a different zone number and age each time. When the user enters the number 0 as the zone number the loo[ and the program should terminate. If the user enters an illegal number or age , no calculation should be done.

Sample output:

Enter the zone number : 4
Enter your age in years : 22
The cost is 6.00

Enter the zone number : 2
Enter your age in years : 14
The cost is 1.85

Enter the zone number : 2
Enter your age in years : 14
Illegal data has been entered.

Enter the zone number : 0
Program Terminated.

Thanxxxxxxx very much in advance.
Jun 12 '07 #1
Share this Question
Share on Google+
1 Reply


ilikepython
Expert 100+
P: 844
Can someone please, please help me in finding the slotuion of the following problem:

The cost of one-day travel cards for adult customers on the metro system is based on which zones they cover and is summarised in the following table:

Zone Cost
1 1.70
1 & 2 3.70
1, 2 & 3 4.70
1, 2, 3 & 4 6.00
1, 2, 3, 4 & 5 6.70
1, 2, 3, 4, 5 & 6 9.10

Passengers who are under 16 years of age travel for half price.

Write a C++ program which allows the user to enter the number of the farthest zone they wish to travel to and their age and calculates and displays the price of the appropriate travel card.

Use a loop parogram so the the above calculation can be done over and over again allowing the user to enter a different zone number and age each time. When the user enters the number 0 as the zone number the loo[ and the program should terminate. If the user enters an illegal number or age , no calculation should be done.

Sample output:

Enter the zone number : 4
Enter your age in years : 22
The cost is 6.00

Enter the zone number : 2
Enter your age in years : 14
The cost is 1.85

Enter the zone number : 2
Enter your age in years : 14
Illegal data has been entered.

Enter the zone number : 0
Program Terminated.

Thanxxxxxxx very much in advance.
We can't write it for you, you have to ask a specific question. Also, please read this when you have time.
Jun 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.