System.out.println("How many items did the customer purchase?");
numOfItem = scan.nextInt();
String numSuffix = "";
for (int i = 1; i \<= numOfItem; ++i) {
String numStr = Integer.toString(i);
if (numStr.length() \> 1 && numStr.charAt(numStr.length() - 2) == '1') {
numSuffix = "th";
System.out.println("Enter the " + i + numSuffix + " item name.");
nameOfItem = scan.nextLine();
} else if (numStr.charAt(numStr.length() - 1) == '1') {
numSuffix = "st";
System.out.println("Enter the " + i + numSuffix + " item name.");
nameOfItem = scan.nextLine();
} else if (numStr.charAt(numStr.length() - 1) == '2') {
numSuffix = "nd";
System.out.println("Enter the " + i + numSuffix + " item name.");
nameOfItem = scan.nextLine();
} else if (numStr.charAt(numStr.length() - 1) == '3') {
numSuffix = "rd";
System.out.println("Enter the " + i + numSuffix + " item name.");
nameOfItem = scan.nextLine();
} else {
numSuffix = "th";
System.out.println("Enter the " + i + numSuffix + " item name.");
nameOfItem = scan.nextLine();
}
System.out.println("How much did this item cost?");
totalPrice += scan.nextDouble();
scan.nextLine();
It should be like : Enter the 1st item name. [user input] How much did this item cost? [user input]
But it always omit the input of the fist item's name like this: Enter the 1st item name. How much did this item cost? [user input]