Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program to solve, in a single execution a predetermined number of quadratic equations of the form: a*x2 + b*x + c =

Write a C++ program to solve, in a single execution a predetermined number of quadratic equations of the form: a*x2 + b*x + c = 0 with the following specific requirements: Please prototype all functions.

0) The number of equations to solve is entered as a command line parameter named number. Make sure that program does not crash, if the command line parameter is not provided.

1) Reading of coefficients a, b, c (all double) shall be done by calling a function named readCoeffs(), which would read all three values from the keyboard, in a single execution, after separate prompt for each coefficient, as follows: Enter coefficient a: Enter coefficient b: Enter coefficient c: This function should pass back all three values to the caller (not return via functions name) via an array parameter named coeffs[].

2) The actual solution of the equation shall be done by a function named equSolver(), which takes three coefficients as an array parameter coeffs[3] and returns a boolean indicator (declared locally, not globally), whether the roots do exist, and in case they do, places them in another array parameter named roots[] composed of two elements (roots).

3) The function equSolver() shall call another function named discr() to calculate and return the discriminant necessary to compute the roots. discr() should also take an array parameter coeffs[].

4) After the equation is solved, another function named outResults() shall take both arrays, coeffs[3] and roots[2] as parameters, and output the results of the calculation, in the following format, to a file or to the screen, respectively, as follows:

a) If the solutions (roots) exist in the real domain, the output shall be directed to a file named results.dat and look exactly as follows: Quadratic equation with the following coefficients: a: ; b: ; c: has the following roots Root1: ; Root2: ;

b) In case there are no solutions (roots) in the real domain, the output shall be directed to the screen and look exactly as follows: Quadratic equation with the following coefficients: a: ; b: ; c: has no roots in the real domain.

5) All functions except discr() have to be called directly from main(), not from each other, in appropriate order.

6) The program has to catch situations, when a=0 is entered, and not do any calculations with it. How to respond exactly is left to the programmer, but a respective message should appear on the screen in each case.

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

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions

Question

What is fuzzy logic?

Answered: 1 week ago