When I try to run what I have so far in my program, I get an error when I enter in the date as 11/11/2010 that states "Exception in thread "main" java.util.InputMismatchException". Why am I getting this and how do I fix it? Also, I have some comments in the program for things I still need to do, but am a bit stuck as to where to go from here concerning the code. Any input is appreciated!
Write a program that displays a simulated paycheck.
The program should ask the user to enter the date,
the payee's name, and the amount of the check. It
should then display a simulated check with the
dollar amount spelled out as shown here:
Date: 11/24/2007
Pay to the Order of: John Phillips $1920.85
One thousand nine hundred twenty and 85 cents
*/
import java.util.Scanner;
import java.text.DecimalFormat;
public class checkWriter
{ // Begin public class checkWriter
public static void main(String[] args)
{ // Begin public static void main(String[] args)
String input; // To hold user's input
int date = 01/01/2010; // To hold the date
String name = ""; // To hold the payee name
double amount = 10.00; // To hold amount of check
// Create a Scanner object to read input
Scanner keyboard = new Scanner(System.in);
// Get date from user
System.out.print("Please enter the date. ");
date = keyboard.nextInt();
// Test the date
// Get the payee name from user
System.out.print("Please enter the payee name. ");
name = keyboard.nextLine();
// Test the payee name
// Get amount of check from user
System.out.print("Please enter amount of check. ");
amount = keyboard.nextDouble();
// Test the amount of the check
// Append values to the object
StringBuilder str = new StringBuilder();
str.append("Date: "); // Append date
str.append("Pay to the Order of: "); // Append payee
str.append("$ "); // Append amount
str.append(" "); // Append word amount
// Display output of check
System.out.println(str);
// Exit system
System.exit(0);
} // End public static void main(String[] args)
} // End public class checkWriter