+ 1
How to solve I didn't understand questionâ
Title: Fare Problem: John is travelling by train, The fare of the train depends on the kilometer he traveled. For the first A kilometer, the fare is M and for the subsequent distance, it is N per kilometer. You are given total distance covered by train. Find out the total fare. Input: Each input contains four space separated Integer A,M,N,D(total distance). Output: Print the value of total fare. Constraints: 1<=A,M,N,D<=1000 Sample Input: 1 2 3 5 Sample Output: 14
7 Answers
+ 4
A=1 <- first km
M=2 <- fare for the first km
N=3 <- fare per km after the first km
D=5 <- total distance
so for the first km the fare is 2. since the total distance is 5km minus the first kilometer 1km, the distance left is 4km, for this 4km price is 3 (because its no longer the first km) so 3 x 4km is 12
12 plus first km fare (2)
12+2 total fare is 14
+ 5
aejaz ahmed another thing,
If you want to mention someone, type @ before their name, not #
Like Taste you tried to mention :)
+ 4
a*m + (d - a) * n
for first a km its m = a*m
remaining dist = (d-a)
remaining fare = (d-a)*n
+ 1
Ok Humayrađ§đ© đ
0
Fare value = fare + (distance travelled * price per km)
D = M + (A*N)
That's the answer if I correctly understood your question.
0
Thanks guys đ«đŹđ I understood the questions and special thanks #taste
0
Taste great explanation! I got the excercise wrong.