• anonymous
I cannot wrap my head around this C++ question: 1. Write a program that finds the solutions, if any, to a given quadratic equation. A quadratic equation is any equation written in the form ax^2 + bx+ c. Keep in mind division by 0 is not permitted and the discriminant b^2-4ac cannot be negative. Use the quadratic formula. Note: if you feel for some reason you do not want to give me the C++ code then you can give me in pseudo-code.
Computer Science
  • Stacey Warren - Expert
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
  • katieb
I got my questions answered at in under 10 minutes. Go to now for free help!
  • anonymous
This is literally exactly the code you need...just in java...not hard to figure out what it should be in c++ - change the system.outs to cout<<....etc...but this should help you out a lot! public static void main(String[] args) { System.out.print("This program solves a quadratic equation.\nEnter the coefficients a b c: "); //get the three variables from user Scanner reader= new Scanner (; double a=reader.nextDouble(); double b=reader.nextDouble(); double c=reader.nextDouble(); //calculate discriminate to determine how many solutions and calculate them double disc=((b*b)-(4*a*c)); double quadP= (-b+Math.sqrt(disc))/(2*a)+0; double quadM= (-b-Math.sqrt(disc))/(2*a)+0; //equation with user's variables System.out.format("Equation: %.2f*x^2 + %.2f*x + %.2f = 0\n", a, b, c); if (a==0.0 && b==0 && c==0) { System.out.println("All real numbers are solutions."); } else if (a==0 && b==0) { System.out.println("There are no real solutions."); } else if (a==0) { double x= ((-c)/(b))+0; System.out.format("There is one real solution: %.2f.\n", x); } else { if (disc<0.00) { System.out.println("There are no real solutions."); } else { if (disc>0.00) { System.out.format("There are two real solutions: %.2f, %.2f.%n", quadM, quadP); } if (disc==0.00) { System.out.format("There is one real solution: %.2f.%n", quadP); } {

Looking for something else?

Not the answer you are looking for? Search for more explanations.