Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class Main1{
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.print("Enter initial speed: ");
- int initialSpeed = scanner.nextInt();
- System.out.print("Enter initial fuel: ");
- int initialFuel = scanner.nextInt();
- if (initialSpeed < 0 || initialFuel < 0) {
- System.out.println("Speed and fuel must be non-negative.");
- return;
- }
- SimpleCar simpleCar = new SimpleCar(initialSpeed, initialFuel);
- simpleCar.accelerate();
- simpleCar.accelerate();
- simpleCar.brake();
- scanner.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment