# Quadratic Formula?

Page 1 of 1

## 5 Replies - 267 Views - Last Post: 07 February 2018 - 08:06 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=409184&amp;s=172f5c0b85c2883dab635929af8a55eb&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 sk3leton

• New D.I.C Head

Reputation: 1
• 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

• D.I.C Regular

Reputation: 21
• 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

• New D.I.C Head

Reputation: 1
• 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

wseng92, 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

• D.I.C Regular

Reputation: 21
• 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

• New D.I.C Head

Reputation: 1
• 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

• D.I.C Regular

Reputation: 21
• 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

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }