I need to make a c++ program for a train ticket system. Below I will list a basics of what I have done and what I need to do. I have done the basics, which includes a list of all the train stops, and also allows the user to input the departure and destination number. Also allowing the user to input number of adults, children and oaps.

But I am not sure how to calculate this and move onto the next step of the program.

I need the program to calculate the adult, child and senior (elderly) fare.

The pricing is below:

The minimum price for all passengers is 15p.For adults per stop it is 10p/ for child per stop it is 6p/ and for senior it is minimum price.

I need to calculate the total minimum cost. Then add the number of adults, children and seniors. Then by adding the total price for the number of passengers that have been inputted into the program.

Once all the calculations have been completed, I then need to display the ticket, in a form which shows the parts below on separate lines in a ticket form.

stop no. ___ stop name ___

no adults ___ children ___ senior ___

adult fare ___ child fare ___ senior fare ___

cost adult ___ child ___ senior ___

Total no persons ___ total fares paid.___

The rest of the program I can do, but this part I can not.I only know basic c++, and it would help if only basic c++ is provided. I have used do/ while loops and for loops so far for other parts of the program. I hope you can help with this Thanks.

you haven't posted your code thus far, so all we've got to go on is what the fare requirement is... a quick glimpse *seems* to indicate if you've got a senior, then the price is the base fare

if you've got a child, then the price is the base fare + 6p per stop

If you've got an adult, then the price is the base fare + 10p per stopif so, then say you've got two seniors, four adults, and five kids along with 10 stops; your algorithm *should* come up:

15p x num of seniors +

15p x num of adults + 10p x num of adults x num of stops +

15p x num of kids + 6p x num of kids x num of stopsI wouldn't worry about presenting the data until your program can spit out the correct fare for the number of passengers. Once you've got that, then tackle the display.

Ask Your Question

Weekly Poll

Did you buy anything on Amazon's Prime Day?

Discuss in The Lounge

Poll History