Computer Science, asked by ramarekha2005, 1 year ago

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 QGP
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.");
    }
}


ramarekha2005: Thanks a lot for your help..... :)
ramarekha2005: seems u love programming...
QGP: Yes I do. Currently I know only JAVA though.
Similar questions