Question: You are to create a program in C++ that computes the roots of the equation ax 2 + bx + c = 0 using the

You are to create a program in C++ that computes the roots of the equation ax2+ bx + c = 0 using the Quadratic Formula:

x = (-b +/- sqrt(b2 - 4 *a*c) )/ 2*a

The program shall read lines containing 3 integers representing a, b, and c from an input text file and writes the set and its corresponding floating-point roots to either an output text file or the screen.

Requirements:

The program will be done in C++ using Cygwin and g++. You may not use stdio.h.

The input file will contain three integers per line, representing values for a, b, and c respectively. Each line of the output file or screen shall contain the set of three integers followed by the two floating-point roots, with all values separated by tabs. All floating-point values shall be printed with 4 digits after the decimal point. If an input set generates complex roots, the output should state complex rather than computing the roots.

All integers in the input file will be between -99 and 99. There is no limit to the size of the input file.

The output file / screen must print the number sets in the same order as they appear in the input file .

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!