TAXIFARE - Editorial

PROBLEM LINK:

Contest

Author: thvardhan

Tester: thvardhan

DIFFICULTY:

cakewalk

PREREQUISITES:

Nothing

PROBLEM:

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.

QUICK EXPLANATION:

We simply use this equation totalFare=first*M+((dist-first)*N)

EXPLANATION:

First we take input from console using scanner or bufferedReader. Now we just use this equation
in abs function like this

totalFare=Math.abs(first*M+((dist-first)*N));

and then we print totalFare with

System.out.println(totalFare);

AUTHOR’S SOLUTION:

author’s solution can be found here

//