Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Converter {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- String consumptionInMiles = input.nextLine();
- int consumptionInMilesNumber= Integer.parseInt(consumptionInMiles);
- if ( 1 <= consumptionInMilesNumber && consumptionInMilesNumber <=100 ){
- double consumptionLitters = Math.floor((4.54 / (consumptionInMilesNumber*1.6))*100);
- System.out.printf("%.0f litres per 100 km", consumptionLitters);
- } else {
- System.out.println(" miles per gallon have to be positive number");
- }
- }
- }
Add Comment
Please, Sign In to add comment