Computer Science, asked by luxmisoni1979, 1 year ago

5. An air-conditioned bus charges fare from the passengers based on the distance travelle
as per the tariff given below:
Fare
80
Distance Travelled
Up to 10 km
11 km to 20 km
21 km to 30 km
31 km and above
Fixed charge
6/km
5/km
*4/km
Design a program to input distance travelled by the passenger. Calculate and display
the fare to be paid.

Answers

Answered by unknowngirl11
153

Answer:

import java .util.*;

public class bus

{

public static void main (String args[ ])

{

Scanner in = new Scanner (System. in);

int d ,f;

System.out.println ("Enter the distance travelled by the passenger ");

d=in.nextInt();

if(d>=0&&d<= 10)

System. out.println (" The fair to be paid = Rs.80");

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

f=d*6;

System. out.println ("The fair to be paid is Rs."+f);

else if (d>=21&&d<=30)

f=d*5;

System. out.println("The fair to be paid is Rs."+f);

else if (d>=31)

f=d*4;

System.out.println("The fair to be paid is Rs."+f);

else

System. out.println ("Wrong Choice");

}

}

HOPE IT HELPS UHH!!!

Answered by poonamandkasturi1234
22

Answer:

import java .util.*;

public class bus

{

public static void main (String args[ ])

{

Scanner in = new Scanner (System. in);

int d ,f;

System.out.println ("Enter the distance travelled by the passenger ");

d=in.nextInt();

if(d>=0&&d<= 10)

System. out.println (" The fair to be paid = Rs.80");

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

f=d*6;

System. out.println ("The fair to be paid is Rs."+f);

else if (d>=21&&d<=30)

f=d*5;

System. out.println("The fair to be paid is Rs."+f);

else if (d>=31)

f=d*4;

System.out.println("The fair to be paid is Rs."+f);

else

System. out.println ("Wrong Choice");

}

}

Similar questions