Write an explanation for the correct answers SCENARIO: Lionel is a student at the School of Fine Art. To help pay his tuition, he took
Write an explanation for the correct answers
SCENARIO: Lionel is a student at the School of Fine Art. To help pay his tuition, he took a job in the school’s student records department. He developed a program that calculates each student’s grade point average (GPA). He thought it would be simple, because he knows that the formula is: total grade points divided by total credit hours attempted However, Lionel’s program crashes with new students who have not attempted any credit hours, instead of just giving them a GPA of 0.0. Here is his code in C# (line numbers added):
1: double GPA; 2: GPA = total GP / credit Hours Attempted; 3: Console. Write Line (GPA);
1. Given what we know about the problem, what is the most likely exception this code will throw?
a. Divide By Zero Exception
b. Null Reference Exception
c. Stack Overflow Exception
2. What structure should Lionel use to handle the exception?
a. do-catch b. catch-exception
c. try-catch
3. Which of the following should Lionel’s catch-block probably include?
a. credit Hours Attempted = 1.0; b. total GP = 4.0; c. GPA = 0.0;
Step by Step Solution
3.50 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1 Unlock smart solutions to boost your understanding
1 The exception most likely creating the problem is a Divide By Zero Exception If a students credit ...83% of Sciences Students Improved their GPA!
Step: 2Unlock detailed examples and clear explanations to master concepts
Step: 3Unlock to practice, ask, and learn with real-world examples
See step-by-step solutions with expert insights and AI powered tools for academic success
- Access 30 Million+ textbook solutions.
- Ask unlimited questions from AI Tutors.
- 24/7 Expert guidance tailored to your subject.
- Order free textbooks.
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started