Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q1. (100 pts.) Making Calculator fool-proof Consider the Calculator class given in Listing 9.5 of the textbook. Your task is to make this program fool-proof:
Q1. (100 pts.) Making Calculator fool-proof Consider the Calculator class given in Listing 9.5 of the textbook. Your task is to make this program fool-proof: any exceptions that may be generated at run-time will be resolved, any invalid input will be corrected through additional user prompts (i.e., ask for another input value) and all problems encountered during execution will be logged into a log file. A (possibly incomplete) list of cases you should code against is as follows: An operand that cannot be cast to double, .Unsupported operator, . Log file cannot be opened for writing Division by 0 Number of arguments is not exactly 3. Add more cases to this list as you see necessary. Name the log file "calculatorLog.txt" and insert a single line of explanation into this file for every problematic case that has been caught. A sample log file might look like this: The first operand was "hello" - program expected a number. The operator was "%"-only +,-, *, / are supported. Division by 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started