The taxi fare in a city is as follows : For the first X kilometre, the fares is M and for the subsequent distance it is N per kilometre. You are given total distance covered by taxi. Find out total fare.
We simply use this equation totalFare=first*M+((dist-first)*N)
First we take input from console using scanner or bufferedReader. Now we just use this equation
in abs function like this
and then we print totalFare with