473,241 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

HELPC++program to decide if the coefficients of a quadratic equation have real roots.

1. write a C++ program to decide if the coefficients of a quadratic equation have real roots. The three choices will be to write the message “zero divide” when A is zero, write the message “no real roots” if the discriminant is negative and find the two roots when there is no error condition. DO NOT FIND THE ROOT IF THERE IS AN ERROR CONDITION.
2. use a NESTED DECISION to do the three parts of the algorithm above.
3. write a sentinel-controlled loop based on a character value to control the loop, q or Q will terminate the loop, any other value will continue processing. Read the value from the keyboard and write to the monitor. Use the inputs given below.
4. document the program properly, see page 3 of the syllabus for the correct style. Use format for both the roots. Be sure to set the iosflags, setprecision, and showpoint. Use a setprecision of 3. also use setw for each numeric output.
5. libraries needed: iostream, cmath, iomanip. Add the .h, math.h for other compilers.


Sample input:
For character variable, and A, B, and C, respectively.
T 2.0 -3.0 -7.0
T 0.0 5.5 1.3
K 3.0 -1.0 10.0
Q//the sentinel value
Sample output
The two roots are -1.266 and 2.766 (first input above)
Zero divide (second input above)
No real roots (third input value)

This is what have so far but i am very confused on what order to put it in

#include <iostream>
#include <math.h>
#include <iomanip>

int main (void)
{
float coefficients
float roots

cout<< "Enter three coefficients of a quadratic equation or Q to quit\n";
cin >> num 1, num 2, num 3
Mar 18 '08 #1
1 2962
weaknessforcats
9,208 Expert Mod 8TB
The order of your numbers is not relevant. What is relevant is that you know what is being entered. That is, if you expect numbers for A, B and C in that order then you need variables for A,B and C. Then when you do your cin>>, you make sure A is the first variable, B the second and so on.

In your code you do not have variables named num1, num2 and num3. All you have are two variables named coefficients and roots. I hope you understand that even though the name is plural, there is just one variable for your coefficients and not three.
Mar 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: parisgoblet | last post by:
hi, i'm a freshman with c++,i got a question from my assignment,does someone could give me some ideas for that. Given the following prototype of a function that solves the roots of a quadratic...
1
by: tedla | last post by:
i want a fragment of code that accepts the coefficient of quadratic equation from user and calculate the eqt'n.
6
by: chronoxx251 | last post by:
Hi, I'm doing a school project where I need to make a program to calulate the quadratic equation. Now, I already got that part taken care of with the following code: #include "stdafx.h" #include...
6
by: Trev17 | last post by:
Hello, I am new to C++ and i have tried for several hours to make a program my teacher has given me as a lab. Here is the Lab question: the roots of the quadratic equation ax^2 + bx + c = 0, a...
4
by: nbkreddy | last post by:
write a program to find the roots of the quadratic equation using switch statement
2
by: ioannoual | last post by:
Hi...I 'am new in C and I want a program that solves a quadratic equation!! I try something by my self to write some code about that but I want you to help me writing a new one that will work!! ...
1
by: bbench123 | last post by:
Make a program that will ask for values of a quadratic equation (ax2+bx+c). the program must determine the roots of the equation using the quadratic equation determinants to distinguish if the roots...
3
by: ginevralupin | last post by:
hi i m a student nd need to write a program to input coefficients of a quadratic equation and output its roots . There is some problem in this , i tried several variations but it is not working....
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.