真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java初級(jí)項(xiàng)目源代碼 Java項(xiàng)目源代碼

求JAVA簡(jiǎn)易計(jì)算機(jī)源代碼

試試這個(gè)

為清徐等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及清徐網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站建設(shè)、網(wǎng)站制作、清徐網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!

import java.util.*;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.applet.*;

public class SZJSQ extends JApplet implements ActionListener

{

boolean i=true;

private JButton num0=new JButton("0");

private JButton num1=new JButton("1");

private JButton num2=new JButton("2");

private JButton num3=new JButton("3");

private JButton num4=new JButton("4");

private JButton num5=new JButton("5");

private JButton num6=new JButton("6");

private JButton num7=new JButton("7");

private JButton num8=new JButton("8");

private JButton num9=new JButton("9");

private JButton zuok=new JButton("(");

private JButton youk=new JButton(")");

private JButton dian=new JButton(".");

private JButton NULL=new JButton("N");

private JButton plu=new JButton("+");

private JButton min=new JButton("-");

private JButton mul=new JButton("x");

private JButton div=new JButton("/");

private JButton equ=new JButton("=");

private JButton cle=new JButton("C");//清除

private JTextField space=new JTextField(30);

public void init()

{

JPanel text=new JPanel();

text.setLayout(new FlowLayout());

text.add(space);

JPanel buttons=new JPanel();

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

buttons.add(num9);

buttons.add(num8);

buttons.add(num7);

buttons.add(plu);

buttons.add(num6);

buttons.add(num5);

buttons.add(num4);

buttons.add(min);

buttons.add(num3);

buttons.add(num2);

buttons.add(num1);

buttons.add(mul);

buttons.add(num0);

buttons.add(cle);

buttons.add(equ);

buttons.add(div);

buttons.add(zuok);

buttons.add(youk);

buttons.add(dian);

buttons.add(NULL);

(num9).addActionListener(this);

(num8).addActionListener(this);

(num7).addActionListener(this);

(num6).addActionListener(this);

(num5).addActionListener(this);

(num4).addActionListener(this);

(num3).addActionListener(this);

(num2).addActionListener(this);

(num1).addActionListener(this);

(num0).addActionListener(this);

(plu).addActionListener(this);

(min).addActionListener(this);

(mul).addActionListener(this);

(div).addActionListener(this);

(equ).addActionListener(this);

(cle).addActionListener(this);

(zuok).addActionListener(this);

(youk).addActionListener(this);

(dian).addActionListener(this);

setLayout(new BorderLayout());

add("North",text);

add("South",buttons);

space.setText("0");

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==num9)

{

if(i==true)

{

space.setText("9");

i=false;

}

else space.setText(space.getText()+'9');

}

if(e.getSource()==num8)

{

if(i==true)

{

space.setText("8");

i=false;

}

else space.setText(space.getText()+'8');

}

if(e.getSource()==num7)

{

if(i==true)

{

space.setText("7");

i=false;

}

else space.setText(space.getText()+'7');

}

if(e.getSource()==num6)

{

if(i==true)

{

space.setText("6");

i=false;

}

else space.setText(space.getText()+'6');

}

if(e.getSource()==num5)

{

if(i==true)

{

space.setText("5");

i=false;

}

else space.setText(space.getText()+'5');

}

if(e.getSource()==num4)

{

if(i==true)

{

space.setText("4");

i=false;

}

else space.setText(space.getText()+'4');

}

if(e.getSource()==num3)

{

if(i==true)

{

space.setText("3");

i=false;

}

else space.setText(space.getText()+'3');

}

if(e.getSource()==num2)

{

if(i==true)

{

space.setText("2");

i=false;

}

else space.setText(space.getText()+'2');

}

if(e.getSource()==num1)

{

if(i==true)

{

space.setText("1");

i=false;

}

else space.setText(space.getText()+'1');

}

if(e.getSource()==num0)

{

if(i==true)

{

space.setText("0");

i=false;

}

else space.setText(space.getText()+'0');

}

if(e.getSource()==zuok)

{

if(i==true)

{

space.setText("(");

i=false;

}

else space.setText(space.getText()+'(');

} if(e.getSource()==youk)

{

if(i==false)

space.setText(space.getText()+')');

}

if(e.getSource()==dian)

{

if(i==false)

space.setText(space.getText()+'.');

}

if(e.getSource()==plu)

{

space.setText(space.getText()+'+');

i=false;

}

if(e.getSource()==min)

{

space.setText(space.getText()+'-');

i=false;

}

if(e.getSource()==mul)

{

space.setText(space.getText()+'*');

i=false;

}

if(e.getSource()==div)

{

space.setText(space.getText()+'/');

i=false;

}

if(e.getSource()==equ)

{

space.setText(String.valueOf(Calculator(space.getText())));

i=true;

}

if(e.getSource()==cle)

{

space.setText("0");

i=true;

}

}

public double Calculator(String f)//科學(xué)計(jì)算

{

int i=0,j=0,k;

char c;

StringBuffer s=new StringBuffer();

s.append(f);

s.append('=');

String formula=s.toString();

char[] anArray;

anArray=new char[50];

StackCharacter mystack=new StackCharacter();

while(formula.charAt(i)!='=')

{

c=formula.charAt(i);

switch(c)

{

case '(': mystack.push(new Character(c));

i++;

break;

case ')':

while(mystack.peek().charValue()!='(')

{

anArray[j++]=mystack.pop().charValue();

}

mystack.pop();

i++;

break;

case '+':

case '-':

while(!mystack.empty()mystack.peek().charValue()!='(')

{

anArray[j++]=mystack.pop().charValue();

}

mystack.push(new Character(c));

i++;

break;

case '*':

case '/':

while(!mystack.empty()(mystack.peek().charValue()=='*'||mystack.peek().charValue()=='/'))

{

anArray[j++]=mystack.pop().charValue();

}

mystack.push(new Character(c));

i++;

break;

case' ': i++;

break;

default: while((c='0'c='9')||c=='.')

{

anArray[j++]=c;

i++;

c=formula.charAt(i);

}

anArray[j++]='#';

break;

}

}

while(!(mystack.empty()))

anArray[j++]=mystack.pop().charValue();

i=0;

int count;

double a,b,d;

StackDouble mystack1 =new StackDouble();

while(ij)

{

c=anArray[i];

switch(c)

{

case '+':

a=mystack1.pop().doubleValue();

b=mystack1.pop().doubleValue();

d=b+a;

mystack1.push(new Double(d));

i++;

break;

case '-':

a=mystack1.pop().doubleValue();

b=mystack1.pop().doubleValue();

d=b-a;

mystack1.push(new Double(d));

i++;

break;

case '*':

a=mystack1.pop().doubleValue();

b=mystack1.pop().doubleValue();

d=b*a;

mystack1.push(new Double(d));

i++;

break;

case '/':

a=mystack1.pop().doubleValue();

b=mystack1.pop().doubleValue();

if(a!=0)

{

d=b/a;

mystack1.push(new Double(d));

i++;

}

else

{

System.out.println("Error!");

}

break;

default:

d=0;count=0;

while((c='0'c='9'))

{

d=10*d+c-'0';

i++;

c=anArray[i];

}

if(c=='.')

{

i++;

c=anArray[i];

while((c='0'c='9'))

{

count++;

d=d+(c-'0')/Math.pow(10,count);

i++;

c=anArray[i];

}

}

if(c=='#')

mystack1.push(new Double(d));

i++;

break;

}

}

return(mystack1.peek().doubleValue());

}

}

求幾個(gè)JAVA小項(xiàng)目源代碼,供自己學(xué)習(xí)參考

package com.test01;

import java.util.Scanner;

public class oop5 { public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

// int x = 9;

// int y = 1;

int x = sc.nextInt();

int y = sc.nextInt();

int z;

z = add(x, y);

System.out.println("x的值為:" + x);

System.out.println("y的值為:" + y);

System.out.println("二者之和為:" + z);

}

/** 四種小算法 */

// 加法運(yùn)算

public static int add(int a, int b) {

int c;

c = a + b;

return c;

}

// 減法運(yùn)算

public static int jian(int d, int v) {

int m;

m = d - v;

return m;

}

// 乘積運(yùn)算

public static int addAdd(int q, int w) {

int e;

e = q * w;

return e;

}

// 除法運(yùn)算

public static int chu(int p, int k) {

int f;

f = p / k;

return f;

}

}

求JAVA入門小程序源代碼

mport java.util.*;

public class HuiWen

{

public static void main(String[] args)

{

Scanner in=new Scanner(System.in);

System.out.println("please input a String:");

String st=in.nextLine();

String s=st.toLowerCase();

int i=0;

int j=s.length()-1;

boolean t=true;

char first=s.charAt(i);

char last=s.charAt(j);

for(;ij;)

{

while(!(first='a'first='z'))

{

i++;

first=s.charAt(i);

}

while(!(last='a'last='z'))

{

j--;

last=s.charAt(i);

}

if(i=j)

break;

if(first==last)

{

i++;

j--;

first=s.charAt(i);

last=s.charAt(j);

}

else

{

t=false;

break;

}

}

if(t)

System.out.println(st+"是回文串");

else

System.out.println(st+"不是回文串");

}

}

//判斷是否為回文字串

//什么實(shí)用的程序,說具體點(diǎn)!你要計(jì)算器的程序嗎?

//下面是計(jì)算器的程序,把分拿來吧!

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Calculator

{

public static void main(String[] args)

{

CalculatorFrame frame=new CalculatorFrame();

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);

}

}

class CalculatorFrame extends JFrame

{

public CalculatorFrame()

{

setTitle("Calculator");

CalculatorPanel panel=new CalculatorPanel();

add(panel);

pack();

}

}

class CalculatorPanel extends Panel

{

public CalculatorPanel()

{

setLayout(new BorderLayout());

result=0;

lastCommand="=";

start=true;

flag=true;

display=new JButton("0");

display.setEnabled(false);

add(display,BorderLayout.NORTH);

ActionListener insert=new InsertAction();

ActionListener command=new CommandAction();

panel=new JPanel();

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

addButton("7",insert);

addButton("8",insert);

addButton("9",insert);

addButton("/",command);

addButton("CE",command);

addButton("4",insert);

addButton("5",insert);

addButton("6",insert);

addButton("*",command);

addButton("Backspace",command);

addButton("1",insert);

addButton("2",insert);

addButton("3",insert);

addButton("-",command);

addButton("sqrt",command);

addButton("0",insert);

addButton(".",insert);

addButton("=",command);

addButton("+",command);

addButton("1/x",command);

add(panel,BorderLayout.CENTER);

}

private void addButton(String label,ActionListener listener)

{

JButton button=new JButton(label);

button.addActionListener(listener);

panel.add(button);

}

private class InsertAction implements ActionListener

{

public void actionPerformed(ActionEvent event)

{

String input=event.getActionCommand();

if(startflag)

{

display.setText("");

start=false;

}

if(flag)

display.setText(display.getText()+input);

}

}

private class CommandAction implements ActionListener

{

public void actionPerformed(ActionEvent event)

{

String command=event.getActionCommand();

if(command.equals("CE"))

{

display.setText("0");

start=true;

flag=true;

command="=";

}

else

if(startflag)

{

if(command.equals("-"))

{

display.setText(command);

start=false;

}

else

if((command.equals("1/x")||command.equals("sqrt"))flag)

calculate(Double.parseDouble(display.getText()),command);

else

if(flag)

lastCommand=command;

}

else

{

if(command.equals("Backspace")flag)

{

String s=display.getText();

char[] s1=s.toCharArray();

if(s.length()=2)

{

String s2=new String(s1,0,s.length()-1);

display.setText(s2);

}

else

{

display.setText("0");

start=true;

}

}

else if(flag)

{

calculate(Double.parseDouble(display.getText()),command);

lastCommand=command;

start=true;

}

}

}

}

public void calculate(double x,String command)

{

if(lastCommand.equals("+")) result+=x;

else if(lastCommand.equals("-")) result-=x;

else if(lastCommand.equals("/"))

{

if(x!=0)

result/=x;

else

{

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

start=false;

flag=false;

return;

}

}

else if(lastCommand.equals("*")) result*=x;

else if(command.equals("1/x"))

{

if(x!=0)

result=1/x;

else

{

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

start=false;

flag=false;

return;

}

}

else if(command.equals("sqrt"))

{

if(x=0)

result=Math.sqrt(x);

else

{

display.setText("函數(shù)輸入無效");

start=false;

flag=false;

return;

}

}

else if(lastCommand.equals("=")) result=x;

display.setText(""+result);

}

private JButton display;

private JPanel panel;

private double result;

private String lastCommand;

private boolean start;

private boolean flag;

}


文章名稱:java初級(jí)項(xiàng)目源代碼 Java項(xiàng)目源代碼
鏈接地址:http://weahome.cn/article/hpjjjd.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部