Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!