Question

CODE MUST BE IN C++ Objective Create a program that provides the solution to a quadratic...

CODE MUST BE IN C++

Objective

Create a program that provides the solution to a quadratic equation.

Background:

A quadratic equation can be generalized by equation below:

f ( x )=ax2+ bx +c

Closed form solutions can be found for the zeros of a quadratic function conveniently. That is the locations

where the function is equal to zero can be found by the following equation:

x=− b± √ b −4ac

2a

Note that depending on the sign of the expression under the square root, your system (problem) may have complex solutions. Therefore your program should be able to produce real number, or complex number solutions.

Your program:

Should prompt the user to choose between quitting, or solving another problem. ASCII character “q” should denote quitting of the session, and “s” should denote solving another problem

If “q” is depressed, the program to terminate execution

If “s” is depressed, the program should proceed to obtain the three values a, b, and c that are needed to define a quadratic equation. You can assume that the user will follow instructions and enter a legal number for the three values (you do not need to worry about exception handling). After this step, your program should produce the two correct solutions.

If your program receives any other input, it should display the choices until one of “q” or “s” is produced

Since it is possible to have complex numbers as your solutions, your program should be prepared to

calculate and display the complex numbers

Your program should have the following functions:

getCoefficients: this function will prompt the user to enter a, b, and c and store them to pass to the solve function

solveQuadratic: this function will take in the values of a, b, and c, solve the equation and store the solution for the print function

printSolutions: this function will print the solution in the form of “real +/- imaginary”

Program requirements:

Your program should be properly commented meaning that it should contain a comment block at the top (with file name, your name, function etc…) as well as comments before each function describing the inputs/output and what the function is doing

Your program should require no math or additional libraries and should only declare the available primitive types

Your program should NOT use global variables.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
CODE MUST BE IN C++ Objective Create a program that provides the solution to a quadratic...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • 10) p. 53, problem 2.4.7. Write a Python program that uses the Quadratic Formula to calculate...

    10) p. 53, problem 2.4.7. Write a Python program that uses the Quadratic Formula to calculate the real solutions to an equation in the form x 2 +bx+c=0 . Prompt the user to enter values for a, b, and c, then display the solutions. For the purposes of this assignment, you may assume that every equation will have two distinct, real solutions. Put your program in the Homework 1 folder on your K: drive. Here is a sample run of...

  • C++ The roots of the quadratic equation ax² + bx + c = 0, a ≠...

    C++ The roots of the quadratic equation ax² + bx + c = 0, a ≠ 0 are given by the following formula: In this formula, the term b² - 4ac is called the discriminant. If b² - 4ac = 0, then the equation has a single (repeated) root. If b² - 4ac > 0, the equation has two real roots. If b² - 4ac < 0, the equation has two complex roots. Instructions Write a program that prompts the...

  • DQuestion 19 28 pts Problem 2. Quadratic Equations A quadratic equation has the form: a bc0 The two solutions are given by the formula: 2a Write a program with a loop that a) solves quadratic equatio...

    DQuestion 19 28 pts Problem 2. Quadratic Equations A quadratic equation has the form: a bc0 The two solutions are given by the formula: 2a Write a program with a loop that a) solves quadratic equations with coefficients read from the terminal, b) visualizes the corresponding quadratic function az2 brc0using the matplotlib module. Instructions Write all code for this problem in a file p2.py 1. The program consists of a main whtle loop (an infinite loop) in which the user...

  • In Python. The two roots of a quadratic equation ax^2 + bx + c = 0...

    In Python. The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula: r1 = (-b + sqrt(b^2 - 4ac) / (2a) and r2 = (-b - sqrt(b^2 - 4ac) / (2a) b^2 - 4ac is called the discriminant of the quadratic equation. If it is positive, the equation has two real roots. If it is zero, the equation has one root. If it is negative, the equation has no...

  • write a C programming code for the following prompt. please use stucture concept and test if...

    write a C programming code for the following prompt. please use stucture concept and test if the code works perfectly. Project Description: In this project, you will write a program to calculate the roots of a quadratic equation. Structure concepts will be used in this project. Your program will prompt the user to enter the coefficients of a quadra coefficientsType. Then it will compute the roots of the quadratic equation and store the result in a structure variable of type...

  • The roots of the quadratic equation ax2 + bx + c = 0, a following formula:...

    The roots of the quadratic equation ax2 + bx + c = 0, a following formula: 0 are given by the In this formula, the term i2 - 4ac is called the discriminant. If b4ac 0 then the equation has a single (repeated) root. If -4ac > 0, th equation complex roots. Write a program that prompts the user to input the value of a (the coefficient of ), b (the coefficient of x), and c (the n has two...

  • please answer this question with python. Write a program to solve the quadratic equation ax^2 +...

    please answer this question with python. Write a program to solve the quadratic equation ax^2 + bx + c = 0 using the standard quadratic formula x = -b plusminus Squareroot b^2 - 4ac/2a or the alternative formula x = 2c/-b Squareroot b^2 - 4ac. Your program should accept values for the coefficients a, b, and c as input and produce the two roots of the equation as output. Your program should detect when the roots are imaginary, but need...

  • c++ language TECH 1211 Computer Programming Name Test 2 Hands-On-Program B Spring 2020 Write a program...

    c++ language TECH 1211 Computer Programming Name Test 2 Hands-On-Program B Spring 2020 Write a program that uses the quadratic formula to solve quadratic equations. Background Given the format for a quadratic equations: aX? +BX+C =0 The coefficient of the X term is the number a. The coefficient of the X term is the number b. The value of c is any non-zero constant. These values can be positive, negative or zero. You can find the solution to this equation...

  • Use Python Programming. Design a class named Quadratic Equation for a quadratic equation ax + bx+c...

    Use Python Programming. Design a class named Quadratic Equation for a quadratic equation ax + bx+c 0. The class contains: • The data fields a, b, and c that represent three coefficients. . An initializer for the arguments for a, b, and c. • Three getter methods for a, b, and c. • A method named get Discriminant() that returns the discriminant, which is b- 4ac The methods named getRoot 1() and getRoot 2() for returning the two roots of...

  • A quadratic equation is generally represented as, ax^2 + bx + c The root(s) of the...

    A quadratic equation is generally represented as, ax^2 + bx + c The root(s) of the above quadratic equation is computed using the following formula, root1 = (-b + sqrt(D))/ 2a root2 = (-b - sqrt(D))/2a Where D is the discriminant of the quadratic equation and is computed as, D = b^2 - 4ac Given the value of D, the roots of a quadratic equation can be categorized as follows, D > 0 : Two distinct real roots D =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT