I want the program to skip to "Enter another?" when N is entered after being prompted "Express?". How can I do that? Now, when N is entered, it still prompts "Long distance?"
Below is the current batch of code. Context: this is the data entry part of the code where user input gets added to an arraylist.
String input=null;
//data entry (user input + adding to arraylist)
do {
System.out.println("Enter parcel code: ");
String pCode=kboard.next();
System.out.println("Enter parcel length: ");
double pLength=kboard.nextDouble();
System.out.println("Enter parcel width: ");
double pWidth=kboard.nextDouble();
System.out.println("Enter parcel height: ");
double pHeight=kboard.nextDouble();
System.out.println("Enter parcel weight: ");
double pWeight=kboard.nextDouble();
Parcel parcel=new Parcel(pCode, pLength, pWidth, pHeight, pWeight);
List.add(parcel);
System.out.println("Express parcel? Y/N: ");
String expressP=kboard.nextLine();
input=kboard.next();
System.out.println("Long distance parcel? Y/N: ");
String longDist=kboard.nextLine();
input=kboard.next();
System.out.println("Do you want to enter another parcel record? Y/N: ");
input=kboard.next();
}
while (input.toLowerCase().equals("y"));
Use 'if-else' conditioning after accepting the input for 'Express Parcel'
This way if user enter N or n it'll ask for next iteration skipping the code for Parcel distance.