Question: package E11; import java.util.Scanner; public class tringal { public static void main(String[] args) { //Scanner for user input Scanner sc = new Scanner(System.in); //Prompt for

 package E11; import java.util.Scanner; public class tringal { public static void

package E11; import java.util.Scanner;

public class tringal { public static void main(String[] args) { //Scanner for user input Scanner sc = new Scanner(System.in); //Prompt for user input System.out.print("Enter a Letter grade: "); char lg = sc.next().charAt(0); //Call method print result System.out.println("The quality points " + qualityPoints(lg));

} //Required method private static double qualityPoints(char lg) {

if (lg == 'A') return 3.75; else if (lg == 'B') return 3; else if (lg == 'C') return 2; else if (lg == 'D') return 1; else }

java

Please add the catch method.

Objectives: In this lab, the following topic will be covered: 1. Exception Handling Task Write a method that returns quality points for a letter grade if it is valid and throws invalid exception otherwise. Write a test program that prompts the user to enter a letter grade and displays the quality points, as presented in the following sample run: Enter a letter grade: A The quality points 3.75 Enter a letter grade: The quality points 2.0 Enter a letter grade: X Invalid grade

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!