![]() |
|
#1
|
|||
|
|||
Quadratic Equation ProgramI have my program below (it runs and compiles as is) , but having difficulty implement these conditions and outputs:
conditions: 1. rejecting certain coefficients if the discriminat (B^(2) -4AC) <0. 2. also having no division by zero in my program (do i use setPrecision)? outputs: having at least 15 spaces or so for each of the root ouput and outputting the roots in the following format: -right justified, four decimal places accuracy, fixed point format -right justified, two decimal places accuracy, floating point (scientific) format - left justified, four decimal places accuracy, fixed point format - left justified, two decimal places accuracy, floating point (scientific) format CPP / C++ / C Code:
Last edited by LuciWiz : 02-Nov-2009 at 15:46.
Reason: Please insert your C++ code between [cpp] & [/cpp] tags
|
|||
|
#2
|
|||
|
|||
Re: Quadratic Equation ProgramQuote:
|
|
#3
|
|||
|
|||
Re: Quadratic Equation Programlol...yes i know..... but can you be more specific please :]
also how do i implement the conditions too! actually want to use cout and cin instead..how would i implement this into my code. Thank You! |
|
#4
|
|||
|
|||
Re: Quadratic Equation ProgramLook at this example for using fixed point or scientific notation. Look at this example for justifying right or left.
As for implementing the conditions, what is the question/problem? |
|
#5
|
|||
|
|||
Re: Quadratic Equation Programhere is the full problem that im trying to do:
trying to make a a program that finds the roots of a quadratic equation. (form: Ax^(2) + Bx + C = 0). Going to prompt the user to enter the coefficients A, B, and C. Also the program can only handle real roots, thus like i said before reject the coefficients if the discriminant (B^(2)-4AC)<0. Also, trying to make the program treat the quadratic equation as a special case, a linear equation, when A is zero. So...like i said before...no division by zero will occur. |
|
#6
|
|||
|
|||
Re: Quadratic Equation Programstill kind of confused after reading over the two links you gave me
changed my code: CPP / C++ / C Code:
|
|
#7
|
|||
|
|||
Re: Quadratic Equation ProgramCPP / C++ / C Code:
|
|
#8
|
|||
|
|||
Re: Quadratic Equation Programhere is my updated code with the justification, scientific/fixed, and spaces
still don't know how to set my code: where it rejects coefficients if the discriminant (B^(2)-4AC) <0. Also having no division of zero in my program (do i use setPrecision) and how ? CPP / C++ / C Code:
|
|
#9
|
|||
|
|||
Re: Quadratic Equation ProgramSince you know what you are going to divide by, simply check that it is not zero after you have collected the user input. For instance:
CPP / C++ / C Code:
|
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 11:13 |
| BOOKEEPING program, HELP!! | yabud | C Programming Language | 10 | 17-Nov-2006 04:48 |
| Help with a complex program | lordfuoco | C++ Forum | 5 | 24-Jun-2006 07:03 |
| ::Need help Please:: using If & Switch in Quadratic equation. | internetbug | C Programming Language | 6 | 07-Apr-2005 18:36 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The