[Java] Main.java Bicycle Car Gas Refueling Refueling

less than 1 minute read

import java.util.Scanner;

class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Bicycle bicycle = new Bicycle(“Bianchi”,”Green”); System.out.println(“[Bicycle information]”); bicycle.printData(); System.out.println(“—————–”); System.out.print(“Please enter the distance to run:”); int bicycleDistance = scanner.nextInt(); bicycle.run(bicycleDistance); System.out.println(“=================”); Car car = new Car(“Ferrari”,”red”); System.out.println(“[car info]”); car.printData(); System.out.println(“—————–”); System.out.print(“Please enter the distance to run:”); int carDistance = scanner.nextInt(); car.run(carDistance); System.out.println(“—————–”); System.out.print(“Please enter the amount to refuel:”); int litre = scanner.nextInt(); car.charge(litre);

} }

Tags:

Updated: