Graderpractice for programmers

Back to 254275 OOP - Labs 6-10 Review

1. Create the Aeroplane class

Problem

Write a class named Aeroplane with fields for "model", "engines" and "seats".

Test code:

class Task1 {

    public static void main(String[] args) {
        Aeroplane ap = input();
        System.out.print("The " + ap.getModel() + " has ");
        System.out.print(ap.getEngines() + " engines and ");
        System.out.println(ap.getSeats() + " seats");
    }

    public static Aeroplane input() {
        Scanner sc = new Scanner(System.in);
        String model = sc.nextLine();
        int engines = Integer.parseInt(sc.nextLine());
        int seats = Integer.parseInt(sc.nextLine());
        return new Aeroplane(model, engines, seats);
    }
}

Examples

Input

Boeing 737 MAX
2
204

Output

The Boeing 737 MAX has 2 engines and 204 seats

Submit your solution

java