I have four user inputs within my setAll method and each user input has a println just before it. The problem that i'm having is the order after the third println.Because it changes in the console stacking two println's one on top of other. I have had this problem before but failed to solve it. I've changed println() to print() and added a newline. I've changed the order of the print() and println() methods to find the proper output in the console. The IED i'm using is NetBeans. If the rest of the code is needed I can add it.
public static void setAll(GuitarSpecifications[] guitarSpecifications, Scanner input) {
for (int index = 0; index < guitarSpecifications.length; index++) {
System.out.println("Enter guitar color: ");
String gColor = input.nextLine();
guitarSpecifications[index].setGuitarColor(gColor);
System.out.println("Enter guitar length: ");
double gLength = input.nextDouble();
guitarSpecifications[index].setGuitarLength(gLength);
System.out.println("Enter number of strings on guitar: ");
int gStrings = input.nextInt();
guitarSpecifications[index].setNumStrings(gStrings);
System.out.println("Enter guitar manufacturer: ");
String gManufacturer = input.nextLine();
guitarSpecifications[index].setGuitarManufacturer(gManufacturer);
}
}
Actual output
run: Enter guitar color: green Enter guitar length: 56.6 Enter number of strings on guitar: 7 Enter guitar manufacturer: Enter guitar color:
Expected output:
Enter guitar color: Blue Enter guitar length: 45.5 Enter number of strings on guitar: 6 Enter guitar manufacturer: Gibson