Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 16, Problem 2PC
Program Plan Intro

Arithmetic Exception

Program Plan:

  • Include the required header files.
  • Create SqrtException class for arithmetic exception.
  • Define the function mySqrt() that accepts the integer parameter.
    • Check whether the number is less than 0. If yes, throw arithmetic exception
    • Loop executes until the square of r is less than or equal to number.
      • Check whether square of r is equal to number. If yes,
        • Return r value.
    • There is no square root, then throw an arithmetic exception.
  • Define the “main()” function.
    • Read the inputs from the user.
    • In the Try block
      • Take square root of given number.
      • Display the square root of number.
    • In the Catch block,
      • Display the error message.

Blurred answer
Students have asked these similar questions
Whats wrong with my pseudocode? Where did I make an error?Code:           Module main()                 Declare Real mileage                 Call getMileage()                 Display “You’ve drive a total of “, mileage, “ miles            End Module                       Module getMilage()                Display “Enter your mileage: “                 Input mileage            End Module
I need help!! Writing a long pseudocode for a modular program that will display the monthly payment on a mortgage.  P=Principal amount borrowed (loan)R=Rate of interest computed for each monthN=Number of months to pay back the loan or mortgageThe help I need is creating a module that you can input the principle, rate of percentage, and years to repay the loan, and another module "displaypayment" that accepts the 3 values and calculates the monthly payment needed for the rates. Lastly 2 local variables needed!Equation:Monthly Payment=[(R*(1+R)^N)/((1+R)^N-1)]*P
Two pseudocode questions I need help with: How do I design a module called findSum that will display the sum of two integer passed by parameter, and a module called findArea that will display the area of a rectangle when passed 2 real values for the length and width of the rectangle?

Chapter 16 Solutions

Starting Out with C++: Early Objects (9th Edition)

Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning