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

簡(jiǎn)單的java計(jì)算機(jī)代碼,java編寫計(jì)算機(jī)

求JAVA編寫的 簡(jiǎn)易計(jì)算器程序,附上注釋

1、首先準(zhǔn)備好軟件即eclipse和java,下載安裝完成后打開eclipse。

創(chuàng)新互聯(lián)公司專注于蘇州企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè),成都商城網(wǎng)站開發(fā)。蘇州網(wǎng)站建設(shè)公司,為蘇州等地區(qū)提供建站服務(wù)。全流程按需定制網(wǎng)站,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)

2、點(diǎn)擊左上角的file 新建一個(gè)project。

3、給project取一個(gè)名字,其他的選項(xiàng)都是默認(rèn)然后點(diǎn)擊finish。

4、接下來是新建一個(gè)class。

5、在給class取名字的時(shí)候注意用英文名的首字母要大寫。完成后點(diǎn)擊finish。

6、這就是開始寫代碼的工作臺(tái),將代碼寫在綠字下。

7、這就是第一個(gè)hello world程序。

急求java簡(jiǎn)易計(jì)算器代碼

試試下面的代碼 絕對(duì)沒有錯(cuò)誤。

package main;

import java.awt.Button;

import java.awt.Color;

import java.awt.GridLayout;

import java.awt.Panel;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.math.BigDecimal;

import javax.swing.JFrame;

import javax.swing.JTextField;

public class app7 extends JFrame implements ActionListener {

static Panel pan = new Panel();

static JTextField textField = new JTextField("0");

static Button b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, bp, ba, bs, bm, bd,

be, bc, bt, bf, bh;

private StringBuffer temp = new StringBuffer("");

private String optValue = "0";

private String optType="";

private boolean isChoiseOptType=true;

public void init() {

b0 = new Button("0");

b0.addActionListener(this);

b1 = new Button("1");

b1.addActionListener(this);

b2 = new Button("2");

b2.addActionListener(this);

b3 = new Button("3");

b3.addActionListener(this);

b4 = new Button("4");

b4.addActionListener(this);

b5 = new Button("5");

b5.addActionListener(this);

b6 = new Button("6");

b6.addActionListener(this);

b7 = new Button("7");

b7.addActionListener(this);

b8 = new Button("8");

b8.addActionListener(this);

b9 = new Button("9");

b9.addActionListener(this);

bp = new Button(".");

bp.addActionListener(this);

ba = new Button("+");

ba.addActionListener(this);

bs = new Button("-");

bs.addActionListener(this);

bm = new Button("*");

bm.addActionListener(this);

bd = new Button("/");

bd.addActionListener(this);

be = new Button("=");

be.addActionListener(this);

bc = new Button("c");

bc.addActionListener(this);

bt = new Button("退格");

bt.addActionListener(this);

bf = new Button("1/x");

bf.addActionListener(this);

bh = new Button("+/-");

bh.addActionListener(this);

this.setTitle("計(jì)算機(jī)");

this.setLayout(null);

this.setSize(260, 300);

this.setResizable(false);

GridLayout grid = new GridLayout(4, 5);

pan.setLayout(grid);

pan.setBounds(20, 60, 150, 120);

textField.setBounds(20, 35, 150, 20);

textField.setBackground(Color.cyan);

textField.setHorizontalAlignment(textField.RIGHT);

textField.setEditable(false);

pan.add(b1);

pan.add(b2);

pan.add(b3);

pan.add(ba);

pan.add(bc);

pan.add(b4);

pan.add(b5);

pan.add(b6);

pan.add(bs);

pan.add(bt);

pan.add(b7);

pan.add(b8);

pan.add(b9);

pan.add(bm);

pan.add(bf);

pan.add(b0);

pan.add(bh);

pan.add(bp);

pan.add(bd);

pan.add(be);

this.add(textField);

this.add(pan);

}

public static void main(String[] args) {

app7 frm = new app7();

frm.init();

frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frm.setVisible(true);

}

@SuppressWarnings("static-access")

@Override

public void actionPerformed(ActionEvent e) {

String value="0";

if (e.getSource().equals(b0)) {

this.temp.append(b0.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(b1)) {

this.temp.append(b1.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(b2)) {

this.temp.append(b2.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(b3)) {

this.temp.append(b3.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(b4)) {

this.temp.append(b4.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(b5)) {

this.temp.append(b5.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(b6)) {

this.temp.append(b6.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(b7)) {

this.temp.append(b7.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(b8)) {

this.temp.append(b8.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(b9)) {

this.temp.append(b9.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(bp)) {

if(this.temp.length()=0)

this.temp.append("0");

this.temp.append(bp.getLabel());

this.textField.setText(this.temp.toString());

isChoiseOptType=false;

} else if (e.getSource().equals(ba)) {

if(!isChoiseOptType){

value=this.textField.getText();

if(value.lastIndexOf(".")==value.length()-1){

value=value.substring(0,value.length()-1);

}

this.optValue=value;

this.temp=new StringBuffer("");

}

this.optType=ba.getLabel();

isChoiseOptType=true;

} else if (e.getSource().equals(bs)) {

if(!isChoiseOptType){

value=this.textField.getText();

if(value.lastIndexOf(".")==value.length()-1){

value=value.substring(0,value.length()-1);

}

this.optValue=value;

this.temp=new StringBuffer("");

}

this.optType=bs.getLabel();

isChoiseOptType=true;

} else if (e.getSource().equals(bm)) {

if(!isChoiseOptType){

value=this.textField.getText();

if(value.lastIndexOf(".")==value.length()-1){

value=value.substring(0,value.length()-1);

}

this.optValue=value;

this.temp=new StringBuffer("");

}

this.optType=bm.getLabel();

isChoiseOptType=true;

} else if (e.getSource().equals(bd)) {

if(!isChoiseOptType){

value=this.textField.getText();

if(value.lastIndexOf(".")==value.length()-1){

value=value.substring(0,value.length()-1);

}

this.optValue=value;

this.temp=new StringBuffer("");

}

this.optType=bd.getLabel();

isChoiseOptType=true;

}else if (e.getSource().equals(be)) {

if(!this.optType.equals("")){

BigDecimal opt1=new BigDecimal(this.optValue);

value=this.textField.getText();

if(value.lastIndexOf(".")==value.length()-1){

value=value.substring(0,value.length()-1);

}

BigDecimal opt2=new BigDecimal(value);

BigDecimal result=new BigDecimal(0);

if(this.optType.equals("+")){

result=opt1.add(opt2);

}else if(this.optType.equals("-")){

result=opt1.subtract(opt2);

}else if(this.optType.equals("*")){

result=opt1.multiply(opt2);

}else if(this.optType.equals("/")){

result=opt1.divide(opt2);

}else if(this.optType.equals("%")){

result=opt1.remainder(opt2);

}

this.textField.setText(result.toString());

this.temp=new StringBuffer("");

isChoiseOptType=false;

this.optValue="0";

}

} else if (e.getSource().equals(bc)) {

this.temp=new StringBuffer();

this.textField.setText("0");

} else if (e.getSource().equals(bt)) {

value=this.textField.getText();

value=value.substring(0,value.length()-1);

if(value.indexOf("-")=0 value.length()=1){

value="0";

this.temp=new StringBuffer("");

}else{

this.temp=new StringBuffer(value);

}

this.textField.setText(value);

}else if (e.getSource().equals(bh)) {

value=this.textField.getText();

if(value.indexOf("-")==0){

value=value.substring(1,value.length());

}else{

value="-"+value;

}

this.temp=new StringBuffer(value);

this.textField.setText(value);

} else if (e.getSource().equals(bf)) {

this.optValue=this.textField.getText();

if(value.lastIndexOf(".")==value.length()-1){

this.optValue=this.optValue.substring(0,this.optValue.length()-1);

}

Integer opt1=new Integer(this.optValue);

if(!opt1.toString().equals("0")){

this.textField.setText(1.0/opt1.intValue()+"");

System.out.println(1/opt1.intValue()+"");

}else{

this.textField.setText("0");

}

this.temp=new StringBuffer("");

this.optType="";

this.optValue="0";

}

}

}

記住類名是app7.java 包名是main. 如果有不對(duì)的地方 到時(shí)候在找我 我在線。

我需要一段最簡(jiǎn)單的java代碼程序

public class HelloWorld{

public static void main(String[] args){

System.out.println("hello world!");

}

}

一. 基本概念

Java是一種可以撰寫跨平臺(tái)應(yīng)用軟件的面向?qū)ο蟮某绦蛟O(shè)計(jì)語言。Java 技術(shù)具有卓越的通用性、高效性、平臺(tái)移植性和安全性,廣泛應(yīng)用于PC、數(shù)據(jù)中心、游戲控制臺(tái)、科學(xué)超級(jí)計(jì)算機(jī)、移動(dòng)電話和互聯(lián)網(wǎng),同時(shí)擁有全球最大的開發(fā)者專業(yè)社群。

二. 體系

Java分為三個(gè)體系,分別為Java SE(J2SE,Java2 Platform Standard Edition,標(biāo)準(zhǔn)版),

JavaEE(J2EE,Java 2 Platform, Enterprise Edition,企業(yè)版)。

Java ME(J2ME,Java 2 Platform Micro Edition,微型版)。

求簡(jiǎn)單JAVA程序代碼,能操作的,簡(jiǎn)單的計(jì)算器有計(jì)算功能+-*/就行越簡(jiǎn)單越好!!!急!!!

public static void main(String[] args) {

String st = "";

計(jì)算器 j = new 計(jì)算器();

boolean t = true;

while (t) {

System.out.print("請(qǐng)輸入計(jì)算代碼:");

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

try {

st = br.readLine();

} catch (IOException ex) {

Logger.getLogger(計(jì)算器.class.getName()).log(Level.SEVERE, null, ex);

}

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

t = false;

} else if (!st.equals("")) {

j.處理(st);

}

}

}

public void 處理(String st) {

if (st.indexOf("+") != -1) {

加(符號(hào)處理(st, "+"));

} else if (st.indexOf("-") != -1) {

減(符號(hào)處理(st, "-"));

} else if (st.indexOf("*") != -1) {

乘(符號(hào)處理(st, "*"));

} else if (st.indexOf("/") != -1) {

除(符號(hào)處理(st, "/"));

}

}

public int[] 符號(hào)處理(String st, String s) {

int[] i = new int[2];

i[0] = Integer.parseInt(st.substring(0, st.indexOf(s)));

i[1] = Integer.parseInt(st.substring(st.indexOf(s) + 1));

return i;

}

public void 加(int x[]) {

System.out.println(x[0] + "+" + x[1] + "=" + (x[0] + x[1]));

}

public void 減(int[] x) {

System.out.println(x[0] + "-" + x[1] + "=" + (x[0] - x[1]));

}

public void 乘(int[] x) {

System.out.println(x[0] + "*" + x[1] + "=" + x[0] * x[1]);

}

public void 除(int x[]) {

if (x[1] == 0) {

System.out.print("除數(shù)不能為零");

return;

}

System.out.println(x[0] + "/" + x[1] + "=" + x[0] / x[1]);

}

可以運(yùn)行:輸入示例:55+62

一個(gè)簡(jiǎn)單的Java程序代碼?

package com.zpp;public class Charge {

public static void main(String [] args) {

if(args.length ==0) {

System.out.println("parameter error!");

System.out.println("java com.zpp.Charge [int]");

return;

}

int min = Integer.parseInt(args[0]);

double money = 0.0;

if (min = 0) {

money =0.0;

System.out.println("not money");

} else if (min = 60) {

money = 2.0;

} else {

money = 2.0 + (min - 60) * 0.01;

}

System.out.println("please pay: " + money);

}

} 編譯:javac -d . Charge.java運(yùn)行:java com.zpp.Charge 111

網(wǎng)站欄目:簡(jiǎn)單的java計(jì)算機(jī)代碼,java編寫計(jì)算機(jī)
地址分享:http://chinadenli.net/article49/dsihghh.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版商城網(wǎng)站網(wǎng)站排名Google企業(yè)建站App設(shè)計(jì)

廣告

聲明:本網(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)站優(yōu)化排名