5 Replies - 267 Views - Last Post: 07 February 2018 - 08:06 PM Rate Topic: -----

#1 sk3leton  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 07-February 18

Quadratic Formula?

Posted 07 February 2018 - 07:52 PM

// A+ Computer Science  -  www.apluscompsci.com
//Name -
//Date -
//Class -
//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)
	{
      a = quadA;
      b = quadB;
      c = quadC;
	}

	public void setEquation(int quadA, int quadB, int quadC)
	{
      
      
 	}

	public void calcRoots( )
	{
      rootOne = (-b + (Math.sqrt(( b* b - ((4 * a * c))))))/ (2 * a);
      rootTwo = (-b - (Math.sqrt((b * b - ((4 * a * c))))))/ (2 * a);
	}

	public void print( )
	{
      out.printf("rootone :: %.2f\n", rootOne);
      out.printf("roottwo :: %.2f\n", rootTwo);
	}
}



Is This A Good Question/Topic? 0
  • +

Replies To: Quadratic Formula?

#2 wseng92  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 428
  • Joined: 23-September 15

Re: Quadratic Formula?

Posted 07 February 2018 - 07:53 PM

Your question is ?
Was This Post Helpful? 0
  • +
  • -

#3 sk3leton  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 07-February 18

Re: Quadratic Formula?

Posted 07 February 2018 - 07:55 PM

import java.util.Scanner; 
import static java.lang.System.*;
import static java.lang.Math.*;

public class QuadraticRunner
{
	public static void main( String[] args )
   {
   	  out.print("Enter a :: ");
        int quadA = keyboard.nextInt();
 
        out.print("Enter b :: ");
        int quadB = keyboard.nextInt();
 
        out.print("Enter c :: ");
        int quadC = keyboard.nextInt();
 
        Quadratic test = new Quadratic(quadA,quadB,quadC);
        test.calcRoots();
        test.print();

   	
		
		
	}
}



This is the runner for the quadratic. I don't understand why it's not running when I did it right

View Postwseng92, on 07 February 2018 - 07:53 PM, said:

Your question is ?


Sorry yes, I put my problem in the post below. For some reason for the runner it shows this
[codeQuadraticRunner.java:22: error: cannot find symbol
int quadC = keyboard.nextInt();
^
[/code]
Was This Post Helpful? 1
  • +
  • -

#4 wseng92  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 428
  • Joined: 23-September 15

Re: Quadratic Formula?

Posted 07 February 2018 - 08:03 PM

You forgot to define keyboard
 Scanner keyboard = new Scanner(System.in);

This post has been edited by wseng92: 07 February 2018 - 08:04 PM

Was This Post Helpful? 1
  • +
  • -

#5 sk3leton  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 07-February 18

Re: Quadratic Formula?

Posted 07 February 2018 - 08:04 PM

Oh! Thanks man!

This post has been edited by ndc85430: 07 February 2018 - 11:41 PM
Reason for edit:: Removed quote of previous post.

Was This Post Helpful? 0
  • +
  • -

#6 wseng92  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 428
  • Joined: 23-September 15

Re: Quadratic Formula?

Posted 07 February 2018 - 08:06 PM

You're welcome.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1