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.21E
Program Plan Intro
- Create a file Test_Exception which throws an exception and the handler throws the same exception again.
- Run the program and record the result.
- To use names in any of the standard C++ header file:
- Header file contains classes used to handle exceptions.
- It contains runtime_error which is used in the program.
Summary Introduction- The program throws an exception. The handler that catches the exception throws it again.
Program Description- The purpose of the program to throw an exception and the handler catches the exception.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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.
(Convert decimals to fractions)Write a program that prompts the user to enter a decimal number and displays the number in a fraction.Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the Rational class in LiveExample 13.13 to obtain a rational number for the decimal number. Use the template athttps://liveexample.pearsoncmg.com/test/Exercise13_19.txt
The problem can not use BigInteger
//Below is the Rational LiveExample 13.13 that goes with the problem/question; notice "long" instead of "BigInteger"
class Rational extends Number implements Comparable<Rational> { // Data fields for numerator and denominator private long numerator = 0; private long denominator = 1;
/** Construct a rational with default properties */ public Rational() { this(0, 1); }
/** Construct a rational with specified numerator and denominator */ public Rational(long numerator, long denominator) { long gcd = gcd(numerator,…
(True/False): When the source code of a program is amended, it must be reassembled and linked before the updated code may be run.
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
- (in JAVA language) Write the following program that id inspired by the photo app 1.Write a try catch block 2.break and continue statement 3.An arrayarrow_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(Local Variable Destructors) Write a program illustrating that all destructors for objectsconstructed in a block are called before an exception is thrown from that block.arrow_forward
- (Stack Unwinding) Write a program that throws an exception from a deeply nested function and still has the catch handler following the try block enclosing the initial call in main catchthe exception.arrow_forward(In java) Lab6C: Cha-Ching For this lab, use a do-while loop.A sentinel loop is a loop (a special while loop or a do-while loop) that continues to process data until itreaches a specific value(s) that signals that it should stop looping; this special value(s) is usuallyindicated as the condition of the while or do-while loop. A good example of a sentinel loop is the whileloop that you had to write to verify user input in Lab6B, the special values were anything in the range of1 to 1000. Another very common application for this is allowing a user to rerun a program.Please write a very simple program that mimics a bank account. The program should start the user outwith $1000. The program should print out a welcome menu once with the options present for the user.The program should allow the user to make a deposit, withdrawal, and see their current balance.Every time the user deposits or withdraws, the program should show the user their new balance; itshould also ask the user if they want…arrow_forward(Computer-Assisted Instruction) The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use a Random object to produce two positive one-digit integers. The program should then prompt the user with a question, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s answer. If it’s correct, display the message "Very good!" and ask another multiplication question. If the answer is wrong, display the message "No. Please try again." and let the student try the same question repeatedly until the student finally gets it right. A separate method should be used to generate each new question. This method should be called once when the application begins execution and each time the user answers the question correctly.arrow_forward
- (java programming language) Write a program to read and store four student’s 21SP registered course and their grade point, sortthem into an order their 21SP registered course, based on grade point from the smallest to the largest,then print them out. The student’s 21SP registered course and their grade point values should be typedin by the user in response to a prompt message. Save the file as SortCourse_yourID.javaarrow_forward(True/False): Passing by reference means that an argument’s address is stored on the runtime stack.arrow_forward(Rethrowing Exceptions) Write a program that illustrates rethrowing an exceptionarrow_forward
- (Hex to binary) Write a program that prompts the user to enter a hex digit and displays its corresponding binary number. Here is sample run: Below are the sample outputs: Enter a hex digit: Ger G is an invalid input Enter a hex digit: Ber The binary value is 1011 Hint: Implement Scanner and use typecasting, Declare a main method Declare a variable to store user input Implement a check for user input Use loop to convert the hexadecimal to decimal Implement a while loop to convert the decimal number to binary Please submit the following: 1. Your flowchart or logic in your program 2. The entire project folder containing your entire project (That includes .java file) as a compressed file. (zip) 3. Program output - screenshot Also, 1. Copy and paste source code to this document underneath the line "your code and results/output" 2. Include flowchart for your program and logical flow and description 3. Include screenshot or your running programarrow_forward(True/False): When a program’s source code is modified, it must be assembled and linkedagain before it can be executed with the changesarrow_forward(Same-number subsequence) JAVA Class Name: Exercise22_05 Write an O(n) program that prompts the user to enter a sequence of integers ending with 0 and finds the longest subsequence with the same number. Sample Run 1 Enter a series of numbers ending with 0:2 4 4 8 8 8 8 2 4 4 0The longest same number sequence starts at index 3 with 4 values of 8 Sample Run 2 Enter a series of numbers ending with 0: 34 4 5 4 3 5 5 3 2 0 The longest same number sequence starts at index 5 with 2 values of 5arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning