?? roots1.java
字號:
import javax.swing.*;
import java.awt.*;
import java.applet.*;
public class roots1 extends Applet
{
public void paint(Graphics g)
{
double a,b,c,deta;
double x1,x2;
a=Double.parseDouble(JOptionPane.showInputDialog("Enter an amout in double,for example 11.25"));
b=Double.parseDouble(JOptionPane.showInputDialog("Enter an amout in double,for example 11.2"));
c=Double.parseDouble(JOptionPane.showInputDialog("Enter an amout in double,for example 1.25"));
deta=b*b-4*a*c;
if(deta==0)
{
x1=(-b)/(2*a);
x2=x1;
g.drawString("x1="+x1,20,40);
g.drawString("x2="+x1,20,60);
}
else if(deta>0)
{
x1=(-b+(float)Math.sqrt(deta))/(2*a);
x2=(-b-(float)Math.sqrt(deta))/(2*a);
g.drawString("x1="+x1,20,40);
g.drawString("x2="+x2,20,60);
}
else if(deta<0)
g.drawString("equation no real root",20,40);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -