write a program in Java that calculates the capacity of an automobile fuel tank in litres , and the kilometers per litre that the automobile can be driven. The program outputs the number of kilometers the automobile can be driven without refuelling.
Answers
Answered by
15
import java.util.Scanner;
public class Mileage
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter capacity of automobile in litres: ");
double cap = sc.nextDouble();
System.out.print("\nEnter the mileage in kilometres per litre: ");
double mil = sc.nextDouble();
System.out.println("\nThe automobile can cover "+(cap*mil)+" kilometres distance on a full tank.");
}
}
public class Mileage
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter capacity of automobile in litres: ");
double cap = sc.nextDouble();
System.out.print("\nEnter the mileage in kilometres per litre: ");
double mil = sc.nextDouble();
System.out.println("\nThe automobile can cover "+(cap*mil)+" kilometres distance on a full tank.");
}
}
ramarekha2005:
Thanks a lot for your help..... :)
Similar questions