Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Oracle Fusion Applications Installation And Administration

Authors: Tushar Thakker

1st Edition

1484209834, 9781484209837

More Books

Students also viewed these Databases questions