Program to report on the roots of a quadratic equation

Assignment Help C/C++ Programming
Reference no: EM13705327

Write a complete C++ program to report on the roots of a quadratic equation ax2 + bx + c = 0, a ≠ 0. The formula for the roots is

-b ± √b2 - 4ac/2a

If the discriminant, b2 - 4ac, is zero, there is a single root. If b2 - 4ac > 0, there are two real roots. If b2 - 4ac < 0, there are two complex roots. For b2 - 4ac >= 0, the program can compute the roots.

Input: The values of a, b, and c are stored in an input file on the h: drive named quadratic.txt.

Processing: A value-returning function will be used to compute b2 - 4ac.

Output: The type and number of the roots (single real root, two real roots, two complex roots) and, if b2 - 4ac >= 0, the root value(s).The output is written to a file on the h: drive named results.txt.

Tip: Use the function pow(x,y), which computes x raised to the power y (xy). If y = 0.5, pow(x,y) gives the square root of x. You need to include the cmath header file to use pow(x,y).

Note: Use the assert function (assert statement) to halt the program if division by zero is about to occur.

Reference no: EM13705327

Questions Cloud

What is the mass of air in the cylinder : The cylinder of a turbocharged diesel engine is filled with air at 30.0 psia and 250°F. When the intake valve closes, cylinder volume is 60.0 in3. The piston moves upward un-til cylinder volume is 4.00 in3, at which time pressure is 1100 psia. What ..
The acceleration of a particle is defined by the equation : The acceleration of a particle is defined by the equation a = -k*sqrt(v), where k is a constant. When t=0, the initial position is xo=0 and the initial velocity is vo=81ft/s. Knowing that v =36ft/s when x=18ft, determine the velocity of the particle ..
Determine how to best maximize the amount of net fixed asset : Analyze the accounting for each fixed asset class using US GAAP and IFRS and determine how to best maximize the amount of net fixed assets.
Change in internal energy of nitrogen in a process : Saturated liquid water at 1.0 MPa is inside a piston­cylinder device, which is heated until all of the water is vaporized. Find the amount of heat transfer needed for this process. Find the change in enthalpy and the change in internal energy of nitr..
Program to report on the roots of a quadratic equation : Write a complete C++ program to report on the roots of a quadratic equation ax2 + bx + c = 0, a ≠ 0. compute the roots.
The mass flow rate of the refrigerant : A small vapor-compression refrigeration unit is to be built into a recreational vehicle and is designed to operate on a 12-volt electrical system. The refrigerator has a cooling capacity of 500 W and uses R-134a. The refrigerant enters the compressor..
Write a program that displays the size of a population : Write a function that calculates the size of the population after a year. To calculate the new population after one year.
Money was made in interest over the initial investment : If a single deposit of $25000 is invested at 1.75% yearly interest, what equal year-end withdrawals can be made each year for 10 years, leaving nothing in the fund after the 10th withdrawal? How much money was made in interest over the initial invest..
Measurement of the flow rate of a stream of liquid acetone : An orifice meter is to be calibrated for the measurement of the flow rate of a stream of liquid acetone. The differential manometer fluid has a specific gravity of 1.10. The calibration is accomplished by connecting the orifice meter in series with a..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Using songs.dat in our folder

Using songs.dat in our folder on the P: drive, construct a playlist of 10 random songs. Use a struct to hold the song data (name and time in seconds), and output the playlist (song name and time,

  Class to act as a generic array

Create a class to act as a generic array (i.e. the user will be able to choose the data type to be stored by passing the appropriate template argument.

  Each person in your team will complete one sequence

each person in your team will complete one sequence problem problem 1 or 2. one selection problem problems 3 4 or

  Write a small program to simulate a raffle

Write a small program to simulate a raffle (a gambling game) for a group with 100 members. You can simply identify each member with a no-duplicated ID numbers from 01 to 100. A number ticket with a positive 4-digits integer number will be randomly cr..

  Design a class named employeerecord

Design a class named EmployeeRecord that holds an employee's ID number, name, and payrate. Include mutator methods to set the values for each data field and output the values for each data field. Create the class diagram and write the code that

  Solve a single quadratic equation of the form

Write a C++ program to solve a single quadratic equation of the form - The actual solution of the equation shall be done by a function named equSolver(), which takes three coefficients as parameters and returns a structure of three fields: two root..

  Create a loops that reads from memory an array

Create a loops that reads from memory an array containing an arbitrary number of characters - The program should make a second character array which is identical to the first, except that the case of every alphabetical letter has been reversed

  Repare a c++ class derived that inherits from base class

Write a C++ class Base has two member functions: //add constructor(s) if needed int f () {return x*25;} //x is a protected data member of Base class virtual int g() {return x *35; }

  Program that stores a series of numbers in a binary tree

Write a program that stores a series of numbers in a binary tree

  Square root of a number n

USING C++ the square root of a number N can be approximated by repeated calculation using the formula NG=.5(LG+N/LG) where NG stands for next guess and LG stands for last guess

  Make a c program that will calculate the gross pay

Write a C program that will calculate the gross pay of a set of employees. For each employee the program should prompt the user to enter the clock number, wage rate, and number of hours as shown below.

  A store with a bag of groceries

write C++ statements that remove all the items from storeBag and place them into one of two new bags, as follows: Place all occurrences of bread and eggs into fragileBag, and all other items into groceryBag. When you are done, storeBag should be empt..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd