473,395 Members | 1,666 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,395 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 2973
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....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.