Questions from Starting Out With Java


Q: The Double.parseDouble() method requires a String argument, but

The Double.parseDouble() method requires a String argument, but it fails if the String cannot be converted to a floating-point number. Write an application in which you try accepting a double input f...

See Answer

Q: Write a program that accepts a number of quarts from a user

Write a program that accepts a number of quarts from a user and converts the value to gallons. Include exception-handling capabilities in the program so that while any nonnumeric value is entered, the...

See Answer

Q: Write a program that prompts the user to enter an integer that

Write a program that prompts the user to enter an integer that represents an array size. Java generates a NumberFormatException if the user attempts to enter a noninteger value using nextInt(). Handle...

See Answer

Q: Write an application that prompts the user to enter an integer and

Write an application that prompts the user to enter an integer and displays its square root. Accept the user’s entry as a String using the nextLine() method. Then try to use the Integer.parseInt() met...

See Answer

Q: Create a CourseException class that extends the Java Exception class and whose

Create a CourseException class that extends the Java Exception class and whose constructor receives a String that holds a college course’s department (for example, CIS), a course number (for example,...

See Answer

Q: Create a UsedCarException class that extends Exception; its constructor receives a

Create a UsedCarException class that extends Exception; its constructor receives a value for a vehicle identification number (VIN) that is passed to the parent constructor so it can be used in a getMe...

See Answer

Q: Create a ScoreException class that extends Exception and whose constructor accepts a

Create a ScoreException class that extends Exception and whose constructor accepts a String parameter and passes it to the Exception class constructor. Save the file as ScoreException.java. b. Write a...

See Answer

Q: Create an Exception class named GradeException that contains a static public array

Create an Exception class named GradeException that contains a static public array of valid grade letters (A, B, C, D, F, and I) that you can use to determine whether a grade is valid. Save the file a...

See Answer

Q: Create a file using any word-processing program or text editor

Create a file using any word-processing program or text editor. Write an application that prompts the user for the filename and displays the file’s path, name, folder, size, and time of last modificat...

See Answer