Answered step by step
Verified Expert Solution
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 ifelse statement
Program Description:
Recall that the quadratic formula, which is used to determine the roots of the general quadratic
equation, is this:
pm
Write a C program that will display to the user the number of real roots of the equation for
different userprovided 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
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
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.
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 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
double root sqrtdiscriminant;
If discriminant were assigned when its value was computed at then root will have the
value after executes!
Specifications:
The program must display clear, explicit prompts for the user.
The program must display clear, understandable statements for all output.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started