Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project Outcomes - Develop a C + + program that: Displays messages to the monitor and reads data from the keyboard using cout and cin

Project Outcomes - Develop a C++ program that:
Displays messages to the monitor and reads data from the keyboard using cout and cin
operators.
Creates and uses different types of variables
Performs assignment operations
Perform basic arithmetic functions
Uses library math functions.
Uses a simple if/else statement
Program Description:
Recall that the quadratic formula, which is used to determine the roots of the general quadratic
equation, is this: x=-b\pm b^24ac/2a
Write a C++ program that will display to the user the number of real roots of the equation for
different user-provided values of a, b, and c, and then computes and displays the real roots (if
there are no real roots, the program should say so).
1. Prompt the user for three values: a, b, and c. The format of the prompt is as follows:
Please enter an integer value for a:
->
Please enter an integer value for b:
->
Please enter an integer value for c:
->
Remember that the user will press after inputting their values, which will drop
the cursor to the next line! Compute the value of the discriminant and use the result to determine how many roots exist
and display that information to the user.
NOTE: the discriminant of the quadratic equation is the value of the arithmetic expression
under the radical
b^2-4ac
Also, the value of the discriminant determines the number of real roots as follows:
Discriminant is positive Two real roots
Discriminant is zero One real root
Discriminant is negative No real roots
You must use the arithmetic operator for multiplication and the assignment operator to store
the computed value into a variable. Once you have computed this value, display the number
of roots you will compute to the user.
3. Compute and display the real roots of the equation. If no real roots exist, display a message
that says so.
An important note: You may be wondering: How are we going to compute a square root? We
will have to get ahead of ourselves a little and use what is called a function from the
library. We will learn about functions in chapter 3, but for now, know that we can use the sqrt()
function from the math library to compute the square root for us!
At the top of your program, include the math library:
#include
Later in your program you can do this:
double discriminant =...(1)
double root = sqrt(discriminant); (2)
If discriminant were assigned 25 when its value was computed at (1), then root will have the
value 5 after (2) executes!
Specifications:
1. The program must display clear, explicit prompts for the user.
2. The program must display clear, understandable statements for all output.

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

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

describe the main employment rights as stated in the law

Answered: 1 week ago