import java.util.Scanner; import java.util.InputMismatchException; /** In this Item class, we'll have a default constructor that * asks the user to enter a name and a price. If there is an * input format error, we handle the problem HERE. */ public class Item { private String name; private double price; /** Default constructor: ask user for input. */ public Item() { Scanner kbd = new Scanner(System.in); System.out.printf("Please enter a name and price: "); try { name = kbd.next(); price = kbd.nextDouble(); } catch (InputMismatchException e) { System.out.printf("Input error! Here is where problem occurred:\n"); e.printStackTrace(); //System.exit(1); } } public String toString() { return name + " $ " + price; } }