Quadratic - { a=quadA; b=quadB; c=quadC; } public void...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//© A+ Computer Science - www.apluscompsci.com //Name - //Date - //Lab - import java.util.Scanner; import static java.lang.System.*; import static java.lang.Math.*; public class Quadratic { private int a, b, c; private double rootOne; private double rootTwo; public Quadratic() { setEquation(0,0,0); rootOne=0; rootTwo=0; } public Quadratic(int quadA, int quadB, int quadC) { setEquation(quadA,quadB,quadC); } public void setEquation(int quadA, int quadB, int quadC)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { a=quadA; b=quadB; c=quadC; } public void calcRoots( ) { double s; s = Math.sqrt(b*b-4*a*c); rootOne= (-b+s)/(2*a); rootTwo= (-b-s)/(2*a); } public void print( ) { System.out.println("\n"); System.out.printf("rootone :: " + "%.2f\n",rootOne ); System.out.printf("roottwo :: " + "%.2f\n",rootTwo ); System.out.println("\n\n"); } }...
View Full Document

Ask a homework question - tutors are online