0

i'm kinda new to Java, i'm learning it for a uni assignment, I have made an if statement that asks the user a series of things, at the moment I've made it so that if the users input for height and length are equal to certain values, add the entered info to an array, however when I enter 5 and 2 to the height and length, it repeats and asks the user again, I'm pretty sure it's a simple thing im missing but im kinda stuck on it haha

public void carInfo(standardSize standard) {

    System.out.println("Please enter number plate: ");
    input = new Scanner(System.in);
    String plate = input.nextLine();

    System.out.println("Please enter car make: ");
    input = new Scanner(System.in);
    String make = input.nextLine();

    System.out.println("Please enter the height of your vehicle: ");
    input = new Scanner(System.in);
    int height = input.nextInt();

    System.out.println("Please enter the length of your vehicle: ");
    input = new Scanner(System.in);
    int length = input.nextInt();

    if (length == 0 || height == 0) {
        System.out.println("cool one");
    }
    else if (length <= 2 && height >= 5) {
        standard.setPlate(plate);
        standard.setCarMake(make);
        standard.setHeight(height);
        standard.setLength(length);
        addStandard();
        System.out.println("working");
    }
    else {
        System.out.println("done");
    }

}

after entering a 5 for height and a 2 for length, it will then ask the user for a number plate again.

0 Answers0