I am trying to create a program that will allow me to read multiple user inputs from the keyboard, for some reason if I read the double first I cant read the string next. What am I missing here ?
import java.util.Scanner;
public class HelloWorld {
public static void main(String[] args) {
Scanner kbd = new Scanner(System.in);
String item1Name, item2Name, item3Name;
double vehicleCapacity, item1Weight, item2Weight, item3Weight;
System.out.print("Please input the vehicles maximum weight capacity in Kilogrammes : ");
vehicleCapacity = kbd.nextDouble();
System.out.println(vehicleCapacity);
System.out.print("Please input the first items name : ");
item1Name = kbd.nextLine();
System.out.println(item1Name);
System.out.println("Program is complete!!");
}
}
I input 100 then hit enter and this is the output then the program ends without allowing me to input the first items name, what am I not understanding?
Please input the vehicles maximum weight capacity in Kilogrammes : 100
100.0
Please input the first items name :
Program is complete!!
Process finished with exit code 0