欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java數(shù)學(xué)軟件代碼 應(yīng)用數(shù)學(xué)的代碼

用java編得計(jì)算器程序軟件和源代碼

java計(jì)算器源程序

成都創(chuàng)新互聯(lián)公司是一家專注于成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)與策劃設(shè)計(jì),雙湖網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)10年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:雙湖等地區(qū)。雙湖做網(wǎng)站價(jià)格咨詢:028-86922220

java計(jì)算器

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

class calculation extends JFrame

{public calculation() /*構(gòu)造方法*/

{super("計(jì)數(shù)器");

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

initTextPanel(); /*文本框*/

initControlPanel(); /*控制鍵*/

initKeyPanel(); /*數(shù)字和運(yùn)算符*/

Container pane = getContentPane();

pane.setLayout(new BorderLayout());

pane.add(TextPanel,BorderLayout.NORTH);

pane.add(ControlPanel,BorderLayout.CENTER);

pane.add(KeyPanel,BorderLayout.SOUTH);

pack();

try

{UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

}

catch(Exception ex)

{;} /*設(shè)置Windons觀感*/

SwingUtilities.updateComponentTreeUI(this);

setResizable(false);

setVisible(true);

}

private void initTextPanel() /*設(shè)置文本框*/

{ TextPanel=new JPanel();

TextPanel.setLayout(new FlowLayout());

Resultarea =new JTextField("0",25);

Resultarea.setEditable(false); /*設(shè)置不可編輯*/

Color color=Color.white;

Resultarea.setBackground(color); /*顏色*/

Resultarea.setHorizontalAlignment(JTextField.RIGHT); /*設(shè)置顯示位置*/

TextPanel.add(Resultarea);

}

private void initControlPanel() /*設(shè)置控制鍵*/

{ControlPanel=new JPanel();

ControlPanel.setLayout(new GridLayout(1,3,4,4));

JButton b1=new JButton("Backspace"); /*Backspace鍵*/

b1.setFont(font1);

b1.addActionListener(new ActionListener()

{public void actionPerformed(ActionEvent e)

{String s1=Resultarea.getText();

int l=s1.length();

Resultarea.setText(s1.substring(0 ,l-1));

}

});

ControlPanel.add(b1);

JButton b2=new JButton("CE"); /*CE鍵*/

b2.setFont(font1);

b2.addActionListener(new ActionListener()

{public void actionPerformed(ActionEvent e)

{Resultarea.setText("0");

isNew=true;

}

});

ControlPanel.add(b2);

JButton b3=new JButton("C"); /*C鍵*/

b3.setFont(font1);

b3.addActionListener(new ActionListener()

{public void actionPerformed(ActionEvent e)

{Resultarea.setText("0");

pnum="";

operation="";

isNew=true;

}

});

ControlPanel.add(b3);

}

private void initKeyPanel() /*設(shè)置數(shù)字鍵和運(yùn)算符鍵*/

{String key[] = {"7","8","9","/","sqrt","4","5","6","*","%","1","2","3","-","1/x","0","+/-",".","+","="};

KeyPanel = new JPanel();

KeyPanel.setLayout(new GridLayout(4,5,4,4));

for(int i=0;i20;i++)

{String label = key[i];

JButton b = new JButton(label);

b.setActionCommand(key[i]);

b.setFont(font2);

KeyPanel.add(b);

b.addActionListener(new ActionListener() /*無(wú)名監(jiān)聽器*/

{public void actionPerformed(ActionEvent e)

{Key_actionPerformed(e);

}

});

}

}

public void Key_actionPerformed(ActionEvent e) /*數(shù)字鍵和運(yùn)算符鍵無(wú)名監(jiān)聽器*/

{String s=(e.getActionCommand());

String st=Resultarea.getText();

if(s.equals("0")) /*輸入數(shù)為0*/

{if(st.equals("0"))

return;

else

{if(!isNew)

Resultarea.setText(st+"0");

else

Resultarea.setText("0");

}

isNew=false;

return;

}

if(s.equals("+/-")) /*輸入數(shù)為+/-*/

{double k=Double.parseDouble(st);

{if(k!=0)

display(-k);

}

return;

}

if(s.equals("1")||s.equals("2")||s.equals("3")||s.equals("4")||s.equals("5")||s.equals("6")||s.equals("7")||s.equals("8")||s.equals("9")) /*輸入1-9*/

{if(!isNew)

Resultarea.setText(st+s);

else

{ Resultarea.setText(s);

isNew=false;

}

return;

}

if(s.equals(".")) /*輸入小數(shù)點(diǎn)*/

{if(Resultarea.getText().indexOf(".")==-1) /*不存在小數(shù)點(diǎn)*/

{if(isNew)

{Resultarea.setText("0.");

isNew=false;

}

else

Resultarea.setText(st+".");

}

return;

}

isNew=true; /*按下運(yùn)算符,輸入新的數(shù)*/

if(s.equals("="))

{compute(s);

operation="";

}

else

{if(s.equals("+")||s.equals("-")||s.equals("*")||s.equals("/")) /*二目運(yùn)算符號(hào)*/

{if(operation.equals(""))

{pnum=Resultarea.getText();

operation=s;

}

else

compute(s);

}

else /*一目運(yùn)算*/

{Count count1=new Count(Double.parseDouble(st));

if(s.equals("sqrt"))

{

display(count1.sqrt());

}

else

{if(s.equals("1/x"))

{if(st.equals("0"))

{Resultarea.setText("除數(shù)不能為0.");

operation="";

pnum="";

}

else

display(count1.reciprocal()); /*求倒數(shù)*/

}

else

display(Double.parseDouble(st)/100); /*輸入%,使當(dāng)前顯示的值除于100*/

}

}

}

}

private void compute(String s)

{if(s.equals("="))

{if(operation.equals(""))

return;

}

double data1=Double.parseDouble(pnum);

double data2=Double.parseDouble(Resultarea.getText());

Count count2=new Count(data1,data2); /*加減乘除計(jì)算*/

if(operation.equals("+"))

display((count2.plus()));

else

{if(operation.equals("-"))

display((count2.minus()));

else

{if(operation.equals("*"))

display((count2.multiply()));

else

if(operation.equals("/"))

{if(data2==0)

{Resultarea.setText("除數(shù)不能為0");

operation="";

pnum="";

return;

}

else

display((count2.divide()));

}

}

}

operation=""; /*符號(hào)為當(dāng)前符*/

pnum=Resultarea.getText();/*運(yùn)算數(shù)為當(dāng)前文本數(shù)*/

}

public void display(double result) /*顯示輸出方法*/

{int a=(int)result;

if(a==result)

Resultarea.setText(String.valueOf(a));

else

Resultarea.setText(String.valueOf(result));

if(Resultarea.getText().equals("NaN"))

Resultarea.setText("輸入函數(shù)無(wú)效");

}

private JPanel TextPanel; /*文本框棉板*/

private JTextField Resultarea; /*文本框*/

private JPanel ControlPanel; /*控制鍵鍵面板*/

private JPanel KeyPanel; /*數(shù)字鍵和運(yùn)算符鍵面板*/

private Font font1=new Font("Dialog",0, 10); /*控制鍵字體*/

private Font font2 = new Font("Dialog",0,10); /*數(shù)字鍵和符號(hào)鍵字體*/

private String pnum=""; /*前操作數(shù)*/

private boolean isNew=true; /*控制是否是新數(shù)*/

private String operation=""; /*運(yùn)算符*/

}

class tester /*測(cè)試類*/

{

public static void main(String[] args)

{

new calculation();

}

}

寫個(gè)java程序求一個(gè)數(shù)的絕對(duì)值

Java是一門面向?qū)ο缶幊陶Z(yǔ)言,不僅吸收了C++語(yǔ)言的各種優(yōu)點(diǎn),還摒棄了C++里難以理解的多繼承、指針等概念,因此Java語(yǔ)言具有功能強(qiáng)大和簡(jiǎn)單易用兩個(gè)特征。Java語(yǔ)言作為靜態(tài)面向?qū)ο缶幊陶Z(yǔ)言的代表,極好地實(shí)現(xiàn)了面向?qū)ο罄碚摚试S程序員以優(yōu)雅的思維方式進(jìn)行復(fù)雜的編程 。

在Java中可以使用Math.abs()方法來方便的進(jìn)行絕對(duì)值計(jì)算,例如

class test {

public static void main(String[] args) {

System.out.println(Math.abs(-8));

}

}

當(dāng)然如果自己寫的話也非常的簡(jiǎn)單,可以這樣做:

public Integer abs(Integer a){return a0?a:-a;

}

當(dāng)輸入的是正數(shù)的時(shí)候直接返回即可,當(dāng)是負(fù)數(shù)的時(shí)候返回它的相反數(shù)即可。使用三目運(yùn)算符可以使用一行代碼就能做到。如果需要輸入Double或者Float類型的參數(shù)的話,代碼基本一樣。

java編一個(gè)計(jì)算器的代碼

界面漂亮堪比系統(tǒng)自帶計(jì)算器,功能完美加減乘除開平方等等全部具備,還有清零按鈕,小數(shù)點(diǎn)的使用,連加連乘功能完全參考系統(tǒng)官方計(jì)算器經(jīng)過長(zhǎng)期調(diào)試改進(jìn)而成,馬上拷貝代碼拿去試試看吧,絕不后悔!

代碼如下:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.util.*;

public class Counter {

public static void main(String[] args) {

CounterFrame frame = new CounterFrame();

frame.show();

}

}

class CounterFrame extends JFrame {

public CounterFrame() {

JMenuBar menuBar = new JMenuBar();

JMenu menuFile = new JMenu();

JMenu menuFile1 = new JMenu();

JMenu menuFile2 = new JMenu();

JMenu menuFile3 = new JMenu();

JMenuItem menuFileExit = new JMenuItem();

menuFile.setText("文件");

menuFile1.setText("編輯");

menuFile2.setText("查看");

menuFile3.setText("幫助");

menuFileExit.setText("退出");

menuFileExit.addActionListener

(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

CounterFrame.this.windowClosed();

}

}

);

menuFile.add(menuFileExit);

menuBar.add(menuFile);

menuBar.add(menuFile1);

menuBar.add(menuFile2);

menuBar.add(menuFile3);

setTitle("計(jì)算器");

setJMenuBar(menuBar);

setSize(new Dimension(400, 280));

this.getContentPane().add(new Allpanel());

this.addWindowListener

(

new WindowAdapter() {

public void windowClosing(WindowEvent e) {

CounterFrame.this.windowClosed();

}

}

);

}

protected void windowClosed() {

System.exit(0);

}

}

class Tool {

public static Tool instance;

private JTextField field;

private Tool() {

this.field=new JTextField(30);

this.field.setHorizontalAlignment(JTextField.RIGHT);

}

public static Tool getinstance()

{

if(instance==null)

{

instance=new Tool();

}

return instance;

}

public JTextField getfield()

{

return (this.field);

}

}

class Allpanel extends JPanel {

public Allpanel() {

this.setLayout(new BorderLayout(0,7));

Northpanel np=new Northpanel();

Centerpanel cp=new Centerpanel();

this.add(np,BorderLayout.NORTH);

this.add(cp,BorderLayout.CENTER);

}

}

class Centercenter extends JPanel {

static Vector Vec=new Vector();

static Vector vc=new Vector();

static Vector vc1=new Vector();

static Vector vc2=new Vector();

static Vector vc3=new Vector();

static String begin="yes";

static double add;

static double jq;

static double cs;

static double cq;

static double dy;

static String jg;

static String what;

static double tool=0;

static String to="yes";

/**

* Method Centercenter

*

*

*/

public Centercenter() {

// TODO: Add your code here

final JTextField text=Tool.getinstance().getfield();

this.setLayout(new GridLayout(4,5,3,3));

String arg[] ={"7","8","9","/","sqrt","4","5","6","*","%","1","2","3","-","1/x","0","+/-",".","+","="};

for(int i=0;i20;i++)

{

final JButton b=new JButton(arg[i]);

//this.add(new JButton(arg[i]));

this.add(b);

if(i==0||i==1||i==2||i==5||i==6||i==7||i==10||i==11||i==12||i==15)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mark=b.getText();

String ma=text.getText();

if(vc3.contains("v3"))

{

text.setText("0."+mark);

vc3.clear();

}

else if(vc.contains("a"))

{

if(vc2.contains("v2"))

{

text.setText("0."+mark);

vc.clear();

vc2.clear();

}

else

{

text.setText(mark);

vc.clear();

Vec.clear();

Vec.add(mark);

}

}

else

{

text.setText(ma.trim()+mark);

Vec.add(mark);

}

begin="no";

to="yes";

}

});

}

if(i==17)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mar=b.getText();

String m=text.getText();

if("yes".equals(begin))

{

vc3.add("v3");

}

if(vc1.contains("v1"))

{

vc2.add("v2");

vc1.clear();

}

if(!Vec.contains(".")!vc.contains("a"))

{

text.setText(m.trim()+mar);

Vec.add(".");

}

}

});

}

if(i==18)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

add=Double.parseDouble(ma);

if(what==null)

{

tool=add;

what="add";

}

else

{

tool=tool+add;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="+";

}

});

}

if(i==13)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

jq=Double.parseDouble(ma);

if(what==null)

{

tool=jq;

what="jq";

}

else

{

tool=tool-jq;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="-";

}

});

}

if(i==3)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

cq=Double.parseDouble(ma);

if(what==null)

{

tool=cq;

what="cq";

}

else

{

tool=tool/cq;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="/";

}

});

}

if(i==4)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

cq=Double.parseDouble(ma);

text.setText(String.valueOf(Math.sqrt(cq)));

}

});

}

if(i==8)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

cs=Double.parseDouble(ma);

if(what==null)

{

tool=cs;

what="cs";

}

else

{

tool=tool*cs;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="*";

}

});

}

if(i==19)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

dy=Double.parseDouble(ma);

if(what=="add")

{

jg=String.valueOf((tool+dy));

}

if(what=="jq")

{

jg=String.valueOf((tool-dy));

}

if(what=="cs")

{

jg=String.valueOf((tool*dy));

}

if(what=="cq")

{

jg=String.valueOf((tool/dy));

}

if(what==null)

{

if(to=="+")

{

tool=add;

jg=String.valueOf(tool+dy);

}

else if(to=="-")

{

tool=jq;

jg=String.valueOf(dy-tool);

}

else if(to=="*")

{

tool=cs;

jg=String.valueOf(dy*tool);

}

else if(to=="/")

{

tool=cq;

jg=String.valueOf(dy/tool);

}

else

{

jg=String.valueOf(dy);

}

}

text.setText(jg);

Vec.clear();

Vec.add(".");

vc.add("a");

vc1.add("v1");

what=null;

tool=0;

}

});

}

}

}

}

class Centernorth extends JPanel {

public Centernorth() {

final JTextField text=Tool.getinstance().getfield();

JButton jb1=new JButton("Backspace");

JButton jb2=new JButton(" CE ");

JButton jb3=new JButton(" C ");

this.add(jb1);

this.add(jb2);

this.add(jb3);

jb1.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e)

{

String back=Tool.getinstance().getfield().getText();

text.setText(backmethod(back));

Centercenter.Vec.remove(Centercenter.Vec.size()-1);

}

});

jb3.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e)

{

text.setText("0.");

Centercenter.Vec.clear();

Centercenter.Vec.add(".");

Centercenter.vc.add("a");

Centercenter.begin="yes";

Centercenter.vc1.clear();

Centercenter.what=null;

Centercenter.tool=0;

}

});

}

public String backmethod(String str)

{

return str.substring(0,str.length()-1);

}

}

class Centerpanel extends JPanel {

public Centerpanel() {

this.setLayout(new BorderLayout(8,7));

Centernorth cn=new Centernorth();

Centercenter cc=new Centercenter();

Centerwest cw=new Centerwest();

this.add(cn,BorderLayout.NORTH);

this.add(cc,BorderLayout.CENTER);

this.add(cw,BorderLayout.WEST);

}

}

class Centerwest extends JPanel {

public Centerwest() {

this.setLayout(new GridLayout(4,1,3,3));

this.add(new JButton("MC"));

this.add(new JButton("MR"));

this.add(new JButton("MS"));

this.add(new JButton("M+"));

}

}

class Northpanel extends JPanel {

private JTextField tf;

public Northpanel() {

tf=Tool.getinstance().getfield();

this.add(tf);

}

}

---------------------------------------------------------------------------

=============《按你要求特意后改過的最簡(jiǎn)單功能的代碼如下》========================

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.util.*;

public class Counter2 {

public static void main(String[] args) {

CounterFrame frame = new CounterFrame();

frame.show();

}

}

class CounterFrame extends JFrame {

public CounterFrame() {

setTitle("計(jì)算器");

setSize(new Dimension(400, 280));

this.getContentPane().add(new Allpanel());

this.addWindowListener

(

new WindowAdapter() {

public void windowClosing(WindowEvent e) {

CounterFrame.this.windowClosed();

}

}

);

}

protected void windowClosed() {

System.exit(0);

}

}

class Tool {

public static Tool instance;

private JTextField field;

private Tool() {

this.field=new JTextField(30);

this.field.setHorizontalAlignment(JTextField.RIGHT);

}

public static Tool getinstance()

{

if(instance==null)

{

instance=new Tool();

}

return instance;

}

public JTextField getfield()

{

return (this.field);

}

}

class Allpanel extends JPanel {

public Allpanel() {

this.setLayout(new BorderLayout(0,7));

Northpanel np=new Northpanel();

Centerpanel cp=new Centerpanel();

this.add(np,BorderLayout.NORTH);

this.add(cp,BorderLayout.CENTER);

}

}

class Centercenter extends JPanel {

static Vector Vec=new Vector();

static Vector vc=new Vector();

static Vector vc1=new Vector();

static Vector vc2=new Vector();

static Vector vc3=new Vector();

static String begin="yes";

static double add;

static double jq;

static double cs;

static double cq;

static double dy;

static String jg;

static String what;

static double tool=0;

static String to="yes";

/**

* Method Centercenter

*

*

*/

public Centercenter() {

// TODO: Add your code here

final JTextField text=Tool.getinstance().getfield();

this.setLayout(new GridLayout(4,5,3,3));

String arg[] ={"7","8","9","/","4","5","6","*","1","2","3","-","0","=",".","+"};

for(int i=0;i16;i++)

{

final JButton b=new JButton(arg[i]);

//this.add(new JButton(arg[i]));

this.add(b);

if(i==0||i==1||i==2||i==4||i==5||i==6||i==8||i==9||i==10||i==12)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mark=b.getText();

String ma=text.getText();

if(vc3.contains("v3"))

{

text.setText("0."+mark);

vc3.clear();

}

else if(vc.contains("a"))

{

if(vc2.contains("v2"))

{

text.setText("0."+mark);

vc.clear();

vc2.clear();

}

else

{

text.setText(mark);

vc.clear();

Vec.clear();

Vec.add(mark);

}

}

else

{

text.setText(ma.trim()+mark);

Vec.add(mark);

}

begin="no";

to="yes";

}

});

}

if(i==14)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mar=b.getText();

String m=text.getText();

if("yes".equals(begin))

{

vc3.add("v3");

}

if(vc1.contains("v1"))

{

vc2.add("v2");

vc1.clear();

}

if(!Vec.contains(".")!vc.contains("a"))

{

text.setText(m.trim()+mar);

Vec.add(".");

}

}

});

}

if(i==15)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

add=Double.parseDouble(ma);

if(what==null)

{

tool=add;

what="add";

}

else

{

tool=tool+add;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="+";

}

});

}

if(i==11)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

jq=Double.parseDouble(ma);

if(what==null)

{

tool=jq;

what="jq";

}

else

{

tool=tool-jq;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="-";

}

});

}

if(i==3)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

cq=Double.parseDouble(ma);

if(what==null)

{

tool=cq;

what="cq";

}

else

{

tool=tool/cq;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="/";

}

});

}

if(i==7)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

cs=Double.parseDouble(ma);

if(what==null)

{

tool=cs;

what="cs";

}

else

{

tool=tool*cs;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="*";

}

});

}

if(i==13)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

dy=Double.parseDouble(ma);

if(what=="add")

{

jg=String.valueOf((tool+dy));

}

if(what=="jq")

{

jg=String.valueOf((tool-dy));

}

if(what=="cs")

{

jg=String.valueOf((tool*dy));

}

if(what=="cq")

{

jg=String.valueOf((tool/dy));

}

if(what==null)

{

if(to=="+")

{

tool=add;

jg=String.valueOf(tool+dy);

}

else if(to=="-")

{

tool=jq;

jg=String.valueOf(dy-tool);

}

else if(to=="*")

{

tool=cs;

jg=String.valueOf(dy*tool);

}

else if(to=="/")

{

tool=cq;

jg=String.valueOf(dy/tool);

}

else

{

jg=String.valueOf(dy);

}

}

text.setText(jg);

Vec.clear();

Vec.add(".");

vc.add("a");

vc1.add("v1");

what=null;

tool=0;

}

});

}

}

}

}

class Centernorth extends JPanel {

public Centernorth() {

final JTextField text=Tool.getinstance().getfield();

}

}

class Centerpanel extends JPanel {

public Centerpanel() {

this.setLayout(new BorderLayout(8,7));

Centernorth cn=new Centernorth();

Centercenter cc=new Centercenter();

Centerwest cw=new Centerwest();

this.add(cn,BorderLayout.NORTH);

this.add(cc,BorderLayout.CENTER);

this.add(cw,BorderLayout.WEST);

}

}

class Centerwest extends JPanel {

public Centerwest() {

}

}

class Northpanel extends JPanel {

private JTextField tf;

public Northpanel() {

tf=Tool.getinstance().getfield();

this.add(tf);

}

}

------------------------------------------------------------

才子_輝祝您愉快!

面向?qū)ο蟪绦蛟O(shè)計(jì)(JAVA)————數(shù)學(xué)三角函數(shù)輔助教學(xué)軟件

import java.awt.Canvas;

import java.awt.Color;

import java.awt.Component;

import java.awt.Container;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.Insets;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JTextField;

import javax.swing.border.Border;

public class Sin extends JFrame{

public static float center_x=0;

public static float center_y=0;

public static JTextField text1;

public static JTextField text2;

public static JTextField text3;

public static double x=0;

public static double y=0;

public Sin(){

final Container con=this.getContentPane();

setLayout(null);

final canvasPanel panel=new canvasPanel();

JLabel lable1=new JLabel("y=asin(bx+c)");

JLabel lable2=new JLabel("a:");

JLabel lable3=new JLabel("b:");

JLabel lable4=new JLabel("c:");

text1=new JTextField(10);

text2=new JTextField(10);

text3=new JTextField(10);

JButton button=new JButton("確定");

//center_x=can.getAlignmentX()/2;

//center_y=can.getAlignmentY()/2;

panel.setBounds(55,10,380,220);

lable1.setBounds(100, 200, 200, 100);

lable2.setBounds(100, 270, 50, 30);

lable3.setBounds(200,270, 50, 30);

lable4.setBounds(300, 270, 50,30);

text1.setBounds(140, 270, 50, 30);

text2.setBounds(240, 270, 50,30);

text3.setBounds(340, 270, 50, 30);

button.setBounds(220, 320,90, 30);

con.add(panel);

con.add(lable1);

con.add(lable2);

con.add(lable3);

con.add(lable4);

con.add(text1);

con.add(text2);

con.add(text3);

con.add(button);

setBounds(350,150,500,450);

button.addActionListener(new ActionListener(){

@Override

public void actionPerformed(ActionEvent arg0) {

// TODO Auto-generated method stub

panel.repaint();

}

});

}

class canvasPanel extends Canvas{

public void paint(Graphics g){

super.paint(g);

Graphics2D g2=(Graphics2D)g;

x=0;

String s1,s2,s3;

s1=text1.getText();s2=text2.getText();s3=text3.getText();

for(int i=0;i300;i++){

int a=10,b=20,c=30;

if(!s1.isEmpty()) a=Integer.parseInt(s1);

if(!s2.isEmpty()) b=Integer.parseInt(s2);

if(!s3.isEmpty()) c=Integer.parseInt(s3);

y=5*(a*Math.sin(b*x+c));

double x2=x+5;

double y2=5*(a*Math.sin(b*(x2)+c));

g2.setColor(Color.red);

g2.drawLine((int)x, (int)y+100, (int)x2, (int)y2+100);

x=x2;

}

}

}

public static void main(String[] args){

new Sin().setVisible(true);

}

}

還存在部分小問題,當(dāng)a,b,c很大的時(shí)候圖就有問題。。。新手。。。只能做到這樣了。。。

本文標(biāo)題:java數(shù)學(xué)軟件代碼 應(yīng)用數(shù)學(xué)的代碼
當(dāng)前鏈接:http://chinadenli.net/article30/doopgpo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)Google全網(wǎng)營(yíng)銷推廣標(biāo)簽優(yōu)化網(wǎng)站設(shè)計(jì)外貿(mào)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)