Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ descriminant = b - 4ac 1) Develop a C++ function template called Discriminant() that calculates and returns the discriminant value There are three template

C++ descriminant = b - 4ac

1) Develop a C++ function template called Discriminant() that calculates and returns the discriminant value

  • There are three template parameters to this function (a, b, c)
  • There is a template return value which is the positive discriminant value (b - 4ac)
    • If the discriminant value is positive, zero included, simply return the value
    • If the discriminant value is negative, then throw an exception with parameter "Discriminant(a, b, c): Negative Discriminant Encountered"
    • Here is a link to a more detailed explanation of exception handling

2) Develop a C++ main function that tests your Discriminant function

  • Prompt the user for values a, b, and c
  • Using your Discriminant function:
    • Print the discriminant value if possible
    • Or else print the exception string if an exception is thrown
  • Prompt the user if they would like to repeat the process another time
    • If the user types "y" or "Y" then repeat the process
    • If the user types "n" or "N" then end the program
    • If the user types in anything else then ask again since these are the only four valid responses

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions