# calculating quadratic formula using netbeans.

Page 1 of 1

## 4 Replies - 11339 Views - Last Post: 23 February 2011 - 06:54 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=218283&amp;s=66eb31d836e415ff30d21e6f1c1395b4&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 umrk

Reputation: 0
• Posts: 11
• Joined: 23-February 11

# calculating quadratic formula using netbeans.

Posted 23 February 2011 - 02:24 PM

```package unit3;

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

{
private int a, b, c;
private double rootOne;
private double rootTwo;

{

rootOne= 0;
rootTwo= 0;

}

{
rootOne=0;
rootTwo=0;

}

{

}

public void calcRoots( ) // I do not understand what I am supposed to write here since I already expressed the formula and calculated the roots.
{

}

public void print( )
// prints the two roots.
{
System.out.printf( "rootone :: " + "%.2f",  (rootOne));
System.out.printf( "rootTwo :: " + "%.2f",  (rootTwo));

```

}
}

Is This A Good Question/Topic? 0

## Replies To: calculating quadratic formula using netbeans.

### #2 m-e-g-a-z

• Winning

Reputation: 497
• Posts: 1,457
• Joined: 19-October 09

## Re: calculating quadratic formula using netbeans.

Posted 23 February 2011 - 02:31 PM

No need to import the lang classes below, they are imported by default.

```import static java.lang.System.*;
import static java.lang.Math.*;

```

### #3 umrk

Reputation: 0
• Posts: 11
• Joined: 23-February 11

## Re: calculating quadratic formula using netbeans.

Posted 23 February 2011 - 02:38 PM

I just don't understand what I am supposed to put inside public void calcRoots().
I already defined the equation using the roots.

### #4 umrk

Reputation: 0
• Posts: 11
• Joined: 23-February 11

## Re: calculating quadratic formula using netbeans.

Posted 23 February 2011 - 02:54 PM

```public void calcRoots()
{
}

```

I don't understand that piece of coding and what I am supposed to write inside of it.

### #5 pbl

• There is nothing you can't do with a JTable

Reputation: 8378
• Posts: 31,956
• Joined: 06-March 08

## Re: calculating quadratic formula using netbeans.

Posted 23 February 2011 - 06:54 PM

I presume your assignment wants you to be able to change the instance variable
```package unit3;

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

{
private int a, b, c;
private double rootOne;
private double rootTwo;

{

rootOne= 0;
rootTwo= 0;

}

{
rootOne=0;
rootTwo=0;

}

{
}

public void calcRoots( ) 	{

rootOne = -(b + Math.sqrt(Math.pow(b, 2))) - 4 * (a * (c)) / (2+a);
rootTwo = -(b - Math.sqrt(Math.pow(b, 2))) - 4 * (a * (c)) / (2+a);

}

public void print( )
// prints the two roots.
{
System.out.printf( "rootone :: " + "%.2f",  (rootOne));
System.out.printf( "rootTwo :: " + "%.2f",  (rootTwo));

```

And by the way the formula is / 2 * a and not / 2 + a