aree categories depending upon the value of the discriminant which is given by b - 4ac rst, if the discriminant is equal to 0, there is only one real root. Then, if the discriminant a positive value, there are two roots which are real and unequal. The roots can be omputed as follows: V - tac 2a urther, if the discriminant is a negative value, then there are two imaginary roots. In mis case, the roots are given by 4ac 2a ogramming tasks: text file, coeff.txt has the folowing information: conft.txt 1 1

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Answer it with C++ programming

Quadratic Root Solver
For a general quadratic equation y = ar' + bx + c, the roots can be dlassified into
three categories depending upon the value of the discriminant which is given by
b - 4ac
First, if the discriminant is equal to 0, there is only one real root. Then, if the discriminant
is a positive value, there are two roots which are real and unequal. The roots can be
computed as follows:
-bt Vb - 4ac
2a
Further, if the discriminant is a negative value, then there are two imaginary roots. In
this case, the roots are given by
- 4ac,
2a
Programming tasks:
A text file, coeff.txt has the folowing information:
coeff.txt
3
5
1
5
1
5
Each line represents the values of a, band c, for a quadratic equation. Write a program
that read these coefficient values, calculate the roots of each quadratic equation, and display
the results. Your program should perform the following tasks:
• Check if the file is successfully opened before reading
• Use loop to read the file from main function
• Use programmer-defined function named calcRoots () to calculate the roots
• Display the type of roots and the root(s) for each equation to console screen.
Format the output to be displayed in floating point numbers, which set to two (2)
decimal places of precision.
• Display a message "There is no solution – not a quadratic" if a equal to 0.
Transcribed Image Text:Quadratic Root Solver For a general quadratic equation y = ar' + bx + c, the roots can be dlassified into three categories depending upon the value of the discriminant which is given by b - 4ac First, if the discriminant is equal to 0, there is only one real root. Then, if the discriminant is a positive value, there are two roots which are real and unequal. The roots can be computed as follows: -bt Vb - 4ac 2a Further, if the discriminant is a negative value, then there are two imaginary roots. In this case, the roots are given by - 4ac, 2a Programming tasks: A text file, coeff.txt has the folowing information: coeff.txt 3 5 1 5 1 5 Each line represents the values of a, band c, for a quadratic equation. Write a program that read these coefficient values, calculate the roots of each quadratic equation, and display the results. Your program should perform the following tasks: • Check if the file is successfully opened before reading • Use loop to read the file from main function • Use programmer-defined function named calcRoots () to calculate the roots • Display the type of roots and the root(s) for each equation to console screen. Format the output to be displayed in floating point numbers, which set to two (2) decimal places of precision. • Display a message "There is no solution – not a quadratic" if a equal to 0.
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY