Computer Science, asked by yadavpalak0805, 9 months ago

Write a JAVA program to input distance travelled by a person and calculate taxi fare according to given slab: distance rate of fare Up to 5 Kms ₹ 25 6 to 10 Kms ₹ 5/Km 11 to 20 Kms ₹ 4/Km 21 Kms or above ₹ 10/5 Kms

Answers

Answered by ramabisa
19

Answer:

Explanation:

import java.util.Scanner;

class taxi

{

public static void main(String[]args)

{

double taxifare;

Scanner in = new Scanner(System.in);

System.out.println("Enter the distance travelled by you in kilometers");

int distance = in.nextInt()

{

if(distance <= 5)

{

taxifare = 25 * distance;

}

else if(distance >= 6 && distance <= 10)

{

taxifare = 5 * distance;

}

else if(distance >= 11 && distance <=20)

{

taxifare = 4 * distance;

}

else if(distance >= 21)

{

taxifare = 2 * distance; //in the given question it is given to be 10/5 when simplified results to 2

}

System.out.println("Taxi Fare: " + taxifare);

}

}

Similar questions