C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 22, Problem 22.15E
Program Plan Intro
To list various type of exceptional conditions that have occurred throughout this text and how the program would handle the exceptions.
Expert Solution & Answer
Explanation of Solution
S. No. | Exception | Exception Handling |
1. | Division by Zero | This exception is handled by defining a catch handler.
Using a try block, the denominator can be verified. If it is zero, the program throws an exception. The catch block catches the exception and informs the user. |
2. | Out-of-range array subscripts | A catch- handler can handle this exception. The code can be placed in a try block. If an error occurs, the exception can be caught by the catch block. |
3. | Arithmetic flow | The code is place in the try block.
If any value exceeds the maximum value permitted, the exception can be thrown. The catch block will catch this exception and print this. |
4. | Arithmetic underflow | Similarly, if any value is lesser than the permitted minimum value, the exception can be thrown by the try block and can be caught by catch block. |
5. | Invalid function parameters | This exception indicates the invalid argument(s) to any function from which it is thrown. This too is handled by using catch block. |
6. | Unsuccessful memory location | This exception is generated when the ‘new’ operator fails to allocate a memory. To handle this exception, place the code in a try block and catch the exception when error is recorded and validated. |
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
(Throwing Exceptions from a catch) Suppose a program throws an exception and the appropriate exception handler begins executing. Now suppose that the exception handler itself throwsthe same exception. Does this create infinite recursion? Write a program to check your observation.
(Constructors Throwing Exceptions) Write a program that shows a constructor passing information about constructor failure to an exception handler after a try block
10) In C++, try-catch blocks can be nested. Also, an exception can be thrown again using “throw; ” true or false
8) Exceptions are run-time anomalies or abnormal conditions that a program encounters during its execution
true or false
Chapter 22 Solutions
C How to Program (8th Edition)
Ch. 22 - Prob. 22.15ECh. 22 - (Catch Parameter) Under what circumstances would...Ch. 22 - (throw Statement) A program contains the statement...Ch. 22 - (Exception Handling vs. Other Schemes) Compare and...Ch. 22 - Prob. 22.19ECh. 22 - Prob. 22.20ECh. 22 - Prob. 22.21ECh. 22 - (Catching Derived-Class Exceptions) Use...Ch. 22 - Prob. 22.23ECh. 22 - Prob. 22.24E
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (Creating Custom Exception Class) Write a Password class that stores a password string. Passwords must contain at least seven alpha-numeric characters, with at least one letter and one digit. Also write an InvalidPasswordException class that extends Exception. The Password constructor should throw an InvalidPasswordException, which should report an appropriate message based on a given string (e.g. if the string contains no digits, the exception should report this fact). Write a GUI program to prompt the user to enter a password and report an InvalidPasswordException if an invalid password is entered. Please teach and help me how to deisgn the program based on the two files given .Some sample screenshots are shown below: InvalidPasswordException.java public class InvalidPasswordException extends Exception{ public InvalidPasswordException (String errMsg){ super(errMsg); } } Password.java public class Password {private String passwordstr; public…arrow_forwardChecked exceptions in Java are those exceptions that are checked at compile time and must be either caught or declared in the method's throws clause. (True/False)arrow_forwardWhat is the purpose of exception specifications? How do you declare a throw list? Can you declare multiple exceptions in a function declaration?arrow_forward
- Python code for the scenario is attached however I'm not just after the code I need also an explanation for all the step your taking when coding this in other work if you are doing a presentation of this to a group of people what are you tell them Analysis:(Describe the problem including input and output in your own words.) UML Class Diagram Algorithm Design: (Describe the major steps for designing the algorithm, for this problem-solving.) Input Validation and Exception Handling in the code Console and Graphical User Interface Code dump/listing Test Plan: (Evidence of testing) Application Testing screenshotsarrow_forwardComputer Science Help please! I need my code to use an exception handling method to check if the user entered a correct word. Here is the logic: When given two words, the child may claim that transformation of the first word into the second is possible. In this case, the program asks the child to demonstrate the correctness of the answer by typing a sequence of words starting with the first and ending with the second. Such a sequence is an acceptable proof sequence if each word is obtained from its predecessor by swapping a single pair of adjacent letters. For example, the sequence tops, tosp, tsop, stop, sotp, sopt, spot proves that the word tops can be transformed into spot. If the proof sequence is accepted, the child earns a point and play proceeds to the next round with a fresh pair of words. A proof sequence is rejected if a word cannot be obtained from its predecessor by swapping an adjacent pair of letters, or if the first word in the sequence is not the first word of the pair…arrow_forward(Handling Related Exceptions) Describe a technique for handling related exceptions.arrow_forward
- List of possible applications/softwares 1 Production management application of "NADEK" Company. Customer Management System of "SACO" Company 3 Repair (Maintenance) service System of the "EXTRA" Company. Track Order System of the "NOON" company. Tasks 1- Choose one application/software from the above list. 2- Apply the "Brainstorming Paradox" to find and write the correspondent exceptions and problems faced by the chosen application or Part of it (specify the part if needed). 3- Apply the SWOT analysis for evaluation of the actual situation (based on the ideas you have about the application).arrow_forwardDefined Exception Handling Exception Handling is used to overcome exceptions that take place during programs’ execution in a systematic manner. For instance, dividing a number by ‘0’ is a mathematical error (not defined). As you learned in class, you can use exception handling to overcome such operations. If you write a code without using exception handling, then the output of division by zero will be shown as infinity which cannot be further processed. Consider the following code: float Division(float num, float den) {return (num / den);} int main() { float numerator = 12.5; float denominator = 0; float result; result = Division(numerator, denominator); cout << "The quotient of 12.5/0 is " << result << endl; }arrow_forward(Member Object Destructors) Write a program illustrating that member object destructorsare called for only those member objects that were constructed before an exception occurred.arrow_forward
- Define the process of Generating the address of an exception handler ?arrow_forwardInstructions: Exception handing Add exception handling to this game (try, catch, throw). You are expected to use the standard exception classes to try functions, throw objects, and catch those objects when problems occur. At a minimum, you should have your code throw an invalid_argument object when data from the user is wrong. File GamePurse.h: class GamePurse { // data int purseAmount; public: // public functions GamePurse(int); void Win(int); void Loose(int); int GetAmount(); }; File GamePurse.cpp: #include "GamePurse.h" // constructor initilaizes the purseAmount variable GamePurse::GamePurse(int amount){ purseAmount = amount; } // function definations // add a winning amount to the purseAmount void GamePurse:: Win(int amount){ purseAmount+= amount; } // deduct an amount from the purseAmount. void GamePurse:: Loose(int amount){ purseAmount-= amount; } // return the value of purseAmount. int GamePurse::GetAmount(){ return purseAmount; } File…arrow_forwardOOP question i) Exceptions can be traced and controlled using conditional statements. ii) For critical exceptions compiler provides the handler A - Only (i) is true B - Only (ii) is true C - Both (i) & (ii) are true D - Both (i) && (ii) are falsearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education