I'm in a stuck with do-while looping that requires looping with do-while until users input one of three correct strings
I've tried with this
Scanner input = new Scanner(System.in);
String motor = "motor";
String mobil = "mobil";
String kosong = "";
String baru = "baru";
int tahun = Calendar.getInstance().get(Calendar.YEAR);
do {
inputVehicleType();
vehicleCondition = input.next();
}
while (!(vehicleCondition.equals(motor)) || (vehicleCondition.equals(mobil)) || (vehicleCondition.equals(kosong)));
System.out.println("SUCCED");
private static void inputVehicleType() {
System.out.println(Constant.HEADER);
System.out.println("Input Jenis Kendaraan Mobil/Motor --> (jenis [motor/mobil])");
titleFooter();
}
with that syntax it only retrieve (vehicleCondition.equals(motor). My expected result was it can retrieve (vehicleCondition.equals(motor), (vehicleCondition.equals(mobil), (vehicleCondition.equals(kosong).