I'm trying to create a program where the user can calculate their daily salary based on when they arrived and left work. I have however received the same error message for the past hour, any help would be greatly appreciated.
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at Tidsrapport.main(Time.java:17)
My code:
import java.util.Scanner;
public class Time {
public static void main(String[] args)
{
int hours, minutes, totalhours;
Scanner keyboard = new Scanner(System.in);
keyboard.useDelimiter("\\s*:\\s*");
System.out.print("When did you arrive at work today [hh:mm]>");
keyboard.nextInt();
System.out.print("When did you leave work today [hh:mm]>");
keyboard.nextInt();
hours = keyboard.nextInt();
minutes = keyboard.nextInt();
totalhours= hours + (minutes/60);
double salary = totalhours * 9;
System.out.println("Your salary today is:" + salary + "dollars");
}
}