I am writing java code to assign inputs from the user to three variables (of type double, string, int). I used scanner for this purpose. It compiled and run perfectly without any error.
My Problem:
I could only input one to the variable of type double (first variable). I couldn't input value to two other variables. Can you explain why this is happening and fix this issue for me?
public class Main {
public static void main(String[] args) {
double revenueTill;
String month;
int dayOfMonth;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter revenue until now: ");
revenueTill = scanner.nextDouble();
System.out.println("Enter month: ");
month = scanner.nextLine();
System.out.println("Enter day of month: ");
dayOfMonth = scanner.nextInt();
MonthPrediction monthPrediction = new MonthPrediction(revenueTill, month, dayOfMonth);
monthPrediction.showRevenueOfMonth(revenueTill, month, dayOfMonth);
}
}