The following program has a function getlnt() that gets input from the input box and converts it to an integer, and a main() function that calls getInt() twice to get two integers, then divides the first integer (dividend) by the second (divisor) and prints the result. Add exception code to getlnt() so when the input cannot be converted to an integer (e.g., it's a letter, word, or floating point number), it ignores it and gets the next input, and keeps doing that until it gets an integer. Add exception code to main() so when the divisor (second integer) is zero, it prints "Cannot divide by zero." and ends. For example, when the input is: 4 the output is: 2.0 When the input is: four 4 zero
The following program has a function getlnt() that gets input from the input box and converts it to an integer, and a main() function that calls getInt() twice to get two integers, then divides the first integer (dividend) by the second (divisor) and prints the result. Add exception code to getlnt() so when the input cannot be converted to an integer (e.g., it's a letter, word, or floating point number), it ignores it and gets the next input, and keeps doing that until it gets an integer. Add exception code to main() so when the divisor (second integer) is zero, it prints "Cannot divide by zero." and ends. For example, when the input is: 4 the output is: 2.0 When the input is: four 4 zero
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter14: Exception Handling
Section: Chapter Questions
Problem 22SA
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
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.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning