内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

java數學軟件代碼 應用數學的代碼

用java編得計算器程序軟件和源代碼

java計算器源程序

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

java計算器

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

class calculation extends JFrame

{public calculation() /*構造方法*/

{super("計數器");

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

initTextPanel(); /*文本框*/

initControlPanel(); /*控制鍵*/

initKeyPanel(); /*數字和運算符*/

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)

{;} /*設置Windons觀感*/

SwingUtilities.updateComponentTreeUI(this);

setResizable(false);

setVisible(true);

}

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

{ TextPanel=new JPanel();

TextPanel.setLayout(new FlowLayout());

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

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

Color color=Color.white;

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

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

TextPanel.add(Resultarea);

}

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

{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() /*設置數字鍵和運算符鍵*/

{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() /*無名監(jiān)聽器*/

{public void actionPerformed(ActionEvent e)

{Key_actionPerformed(e);

}

});

}

}

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

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

String st=Resultarea.getText();

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

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

return;

else

{if(!isNew)

Resultarea.setText(st+"0");

else

Resultarea.setText("0");

}

isNew=false;

return;

}

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

{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(".")) /*輸入小數點*/

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

{if(isNew)

{Resultarea.setText("0.");

isNew=false;

}

else

Resultarea.setText(st+".");

}

return;

}

isNew=true; /*按下運算符,輸入新的數*/

if(s.equals("="))

{compute(s);

operation="";

}

else

{if(s.equals("+")||s.equals("-")||s.equals("*")||s.equals("/")) /*二目運算符號*/

{if(operation.equals(""))

{pnum=Resultarea.getText();

operation=s;

}

else

compute(s);

}

else /*一目運算*/

{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("除數不能為0.");

operation="";

pnum="";

}

else

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

}

else

display(Double.parseDouble(st)/100); /*輸入%,使當前顯示的值除于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); /*加減乘除計算*/

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("除數不能為0");

operation="";

pnum="";

return;

}

else

display((count2.divide()));

}

}

}

operation=""; /*符號為當前符*/

pnum=Resultarea.getText();/*運算數為當前文本數*/

}

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("輸入函數無效");

}

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

private JTextField Resultarea; /*文本框*/

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

private JPanel KeyPanel; /*數字鍵和運算符鍵面板*/

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

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

private String pnum=""; /*前操作數*/

private boolean isNew=true; /*控制是否是新數*/

private String operation=""; /*運算符*/

}

class tester /*測試類*/

{

public static void main(String[] args)

{

new calculation();

}

}

寫個java程序求一個數的絕對值

Java是一門面向對象編程語言,不僅吸收了C++語言的各種優(yōu)點,還摒棄了C++里難以理解的多繼承、指針等概念,因此Java語言具有功能強大和簡單易用兩個特征。Java語言作為靜態(tài)面向對象編程語言的代表,極好地實現(xiàn)了面向對象理論,允許程序員以優(yōu)雅的思維方式進行復雜的編程 。

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

class test {

public static void main(String[] args) {

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

}

}

當然如果自己寫的話也非常的簡單,可以這樣做:

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

}

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

java編一個計算器的代碼

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

代碼如下:

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("計算器");

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);

}

}

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

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

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("計算器");

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);

}

}

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

才子_輝祝您愉快!

面向對象程序設計(JAVA)————數學三角函數輔助教學軟件

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);

}

}

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

本文標題:java數學軟件代碼 應用數學的代碼
當前鏈接:http://m.rwnh.cn/article30/doopgpo.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供手機網站建設Google、全網營銷推廣標簽優(yōu)化、網站設計、外貿網站建設

廣告

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

成都網站建設
固阳县| 调兵山市| 佛山市| 卓资县| 凌源市| 巴林右旗| 缙云县| 罗城| 霍州市| 珲春市| 原平市| 南溪县| 自贡市| 临湘市| 阿拉善右旗| 屏山县| 监利县| 江口县| 博爱县| 彝良县| 东莞市| 固安县| 武定县| 乐清市| 普兰县| 抚州市| 紫云| 郴州市| 来安县| 安乡县| 瑞丽市| 新郑市| 商河县| 龙川县| 民权县| 巩留县| 法库县| 济宁市| 弥渡县| 阳泉市| 永靖县|