I need help in understanding this c++ program...

+1 vote
asked Nov 23, 2018 by F.Z.M
  1. A taxicab company calculates charges using a fixed $3.20 hire charge, a $2.05-per-kilometer charge for the distance covered, and an additional $0.95-per-minute charge based on the duration of the journey, in minutes. If the journey starts between 2300 and 0600 hours, a 15% surcharge is applied.

Write a program that asks the user to input the duration of the journey (rounded up to the nearest minute), the distance traveled (in kilometers), and the journey start time (as a 24-hour single int value). The program should then output the fare that should be charged.

1 Answer

0 votes
answered Nov 23, 2018 by Юрий Гуреев (1,100 points)
Best answer

You need to implement the following logic:


  duration = HHMM (HH - hours, MM - minutes)

  distance = kilometers


  hire = 3.20 + 2.05 x distance + 0.95 x minutes;

  if ((journeyStarts >= 2300 AND journeyStarts <=2400) OR (journeyStarts >= 0000 AND journeyStarts <= 0600)) then

    hire = hire + 0.15 x hire;

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.