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

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

java小程序代碼短 小程序代碼大小

急求大神發(fā)幾個java 300行代碼的小程序 簡單點的

/**

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

* 文件名:Operation.java 2014-1-2 下午3:06:37

* @author Administrator

*/

package cc.icoc.javaxu.action;

import java.util.ArrayList;

import java.util.Scanner;

import cc.icoc.javaxu.datas.StudentInfo;

/**

* @author 許仕永

* 創(chuàng)建時間: 2014 2014-1-2 下午3:06:37

*/

public class Operation

{

int stuNo,stuAge;

String stuName,stuClass,stuSex;

ArrayListStudentInfo list;

/**程序入口

* @param args

*/

public static void main(String[] args)

{

// TODO Auto-generated method stub

new Operation().operation();

}

private int inputInt()

{

Scanner scanner = new Scanner(System.in);

return scanner.nextInt();

}

private String inputStr()

{

Scanner scanner = new Scanner(System.in);

return scanner.nextLine();

}

private void operation()

{

// TODO Auto-generated method stub

if(list == null)

{

list = new ArrayListStudentInfo();

}

while(true)

{

System.out.println("\t\t\t學(xué)生信息管理系統(tǒng)\n");

System.out.println("1.信息查閱");

System.out.println("2.信息查詢");

System.out.println("3.信息錄入");

System.out.println("4.退出系統(tǒng)");

int what = inputInt();

if ( what == 1 )

{

getInfo();

} else if ( what == 2 )

{

allSerach();

} else if ( what == 3 )

{

inputInfo();

} else if( what == 4 )

{

System.out.println("已經(jīng)退出系統(tǒng)");

System.exit(0);

}

}

}

/**

* 獲取全部學(xué)生的信息列表

*/

private void getInfo()

{

if(!list.isEmpty())

{

for ( int i = 0; i list.size(); i++ )

{

System.out.println(list.get(i));

}

}

}

/**

* 執(zhí)行查找

*/

private void allSerach()

{

System.out.println("1.輸入學(xué)號進行查詢");

System.out.println("2.輸入姓名進行查詢");

int what = inputInt();

if(what == 1)

{

System.out.println("請輸入學(xué)號:");

search(inputInt());

}

else

{

System.out.println("請輸入姓名:");

search(inputStr());

}

}

/**

* 按學(xué)生姓名查詢學(xué)生信息

* @param name 學(xué)生姓名

*/

private StudentInfo search(String name)

{

for ( int i = 0; i list.size(); i++ )

{

if(list.get(i).getStuName().equals(name))

{

System.out.println(list.get(i));

return list.get(i);

}

}

System.out.println("未查詢到該名字的學(xué)生");

return null;

}

/**

* 按學(xué)號查詢學(xué)生信息

* @param id 學(xué)號

*/

private StudentInfo search(int id)

{

for ( int i = 0; i list.size(); i++ )

{

if(list.get(i).getStuNo()==id)

{

System.out.println(list.get(i));

return list.get(i);

}

}

System.out.println("未查詢到該學(xué)號的學(xué)生");

return null;

}

/**

* 錄入學(xué)生信息

*/

private void inputInfo()

{

try

{

System.out.print("請輸入學(xué)生學(xué)號:\n");

stuNo = inputInt();

System.out.print("請輸入學(xué)生姓名:\n");

stuName = inputStr();

System.out.print("請輸入學(xué)生性別:\n");

stuSex = inputStr();

System.out.print("請輸入學(xué)生年齡:\n");

stuAge = inputInt();

System.out.print("請輸入學(xué)生班級:\n");

stuClass = inputStr();

list.add(new StudentInfo(stuNo, stuAge, stuName, stuSex, stuClass));

} catch (Exception e)

{

// TODO: handle exception

System.out.println("不允許為空,請重新輸入");

}

}

}

package cc.icoc.javaxu.action;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class Stu

{

int countStu = 0;

int sum = 0;

int avg = 0;

ListStuBean list = new ArrayListStu.StuBean();

public static void main(String[] args)

{

new Stu().go();

}

private void go()

{

A:while(true)

{

//構(gòu)造實體Bean來存儲學(xué)生成績

StuBean bean = new StuBean();

System.out.println("請輸入成績:");

System.out.println("語文:");

bean.setYuwen(scanner());

System.out.println("數(shù)學(xué):");

bean.setMath(scanner());

//獲取英語成績

System.out.println("英語:");

bean.setEnglish(scanner());

//存入容器

list.add(bean);

for ( int i = 0; i list.size(); i++ )

{

sum += list.get(i).english+list.get(i).math+list.get(i).yuwen;

}

avg = sum / (3*list.size());

System.out.println("當(dāng)前有"+list.size()+"條學(xué)生記錄,所有學(xué)生總分="+sum+"平均分為"+avg);

//輸入y繼續(xù)錄入學(xué)生信息,輸入x退出

System.out.println("\n已成功錄入一個學(xué)生的數(shù)據(jù),是否繼續(xù)/退出(y/x)");

if("x".equals(scannerString()))

break A;

}

}

/**輸入*/

private int scanner()

{

Scanner scanner = new Scanner(System.in);

return scanner.nextInt();

}

/**輸入*/

private String scannerString()

{

Scanner scanner = new Scanner(System.in);

return scanner.nextLine();

}

class StuBean

{

int math;

int yuwen;

int english;

public int getMath()

{

return math;

}

public void setMath(int math)

{

this.math = math;

}

public int getYuwen()

{

return yuwen;

}

public void setYuwen(int yuwen)

{

this.yuwen = yuwen;

}

public int getEnglish()

{

return english;

}

public void setEnglish(int english)

{

this.english = english;

}

}

}

/**

* 文件名:StudentInfo.java 2014-1-2 下午3:07:29

* @author Administrator

*/

package cc.icoc.javaxu.datas;

/**

* @author 許仕永

* 創(chuàng)建時間: 2014 2014-1-2 下午3:07:29

*/

public class StudentInfo

{

int stuNo,stuAge;

String stuName,stuSex,stuClass;

public StudentInfo(int stuNo, int stuAge, String stuName, String stuSex, String stuClass)

{

super();

this.stuNo = stuNo;

this.stuAge = stuAge;

this.stuName = stuName;

this.stuSex = stuSex;

this.stuClass = stuClass;

}

public int getStuNo()

{

return stuNo;

}

public void setStuNo(int stuNo)

{

this.stuNo = stuNo;

}

public int getStuAge()

{

return stuAge;

}

public void setStuAge(int stuAge)

{

this.stuAge = stuAge;

}

public String getStuName()

{

return stuName;

}

public void setStuName(String stuName)

{

this.stuName = stuName;

}

public String getStuSex()

{

return stuSex;

}

public void setStuSex(String stuSex)

{

this.stuSex = stuSex;

}

public String getStuClass()

{

return stuClass;

}

public void setStuClass(String stuClass)

{

this.stuClass = stuClass;

}

@Override

public String toString()

{

// TODO Auto-generated method stub

String s = "學(xué)號:"+getStuNo()+"\t姓名:"+getStuName()+" \t性別:"+getStuSex()+"\t年齡:"+getStuAge()+"\t班級:"+getStuClass();

return s;

}

}

誰能給個JAVA的小程序代碼,越小越好!

這是我曉得的最簡單的java小程序代碼了你可以看看:

package com.kenki.emp;

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import java.util.*;

import java.sql.SQLException;

import java.sql.*;

public class emp extends HttpServlet {

private static final String CONTENT_TYPE = "text/html; charset=GBK";

//Initialize global variables

public void init() throws ServletException {

}

//Process the HTTP Get request

public void doGet(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

response.setContentType(CONTENT_TYPE);

PrintWriter out = response.getWriter();

String code = request.getParameter("code");

String name = request.getParameter("name");

String pay = request.getParameter("pay");

System.out.println("empcode:" + code);

System.out.println("name:" + name);

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

//創(chuàng)建驅(qū)動

new com.microsoft.jdbc.sqlserver.SQLServerDriver();

String strd =

"jdbc:microsoft:sqlserver://localhost:1433;databasename=emp_dates";

String username = "sa";

String pws = "";

try {

java.sql.Connection conn = java.sql.DriverManager.getConnection(

strd, username, pws);

String strs = "insert into emp values(?,?,?)";

java.sql.PreparedStatement pre = conn.prepareStatement(strs);

pre.setString(1, code);

pre.setString(2, name);

pre.setString(3, pay);

pre.execute();

pre.close();

conn.close();

//重定向至查詢頁面

out.println("成功保存!!");

response.sendRedirect("emp.html");

} catch (SQLException ss) {

ss.printStackTrace();

response.sendRedirect("/WebModule1/error.html");

}

}

//Process the HTTP Post request

public void doPost(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

doGet(request, response);

}

//Clean up resources

public void destroy() {

}

}

JAVA小程序編寫

1.JavaPow.java

import java.util.Scanner;

public class JavaPow {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("請輸入一個數(shù)求平方:");

double num = sc.nextDouble();

System.out.println(num + "的平方結(jié)果是:" + Math.pow(num, 2));

}

}

2.CompareTest.java

public class CompareTest {

public static void main(String[] args) {

int a = 10, b = 8;

if(ab){

System.out.println("排序結(jié)果是:"+b+"\t"+a);

}else{

System.out.println("排序結(jié)果是:"+a+"\t"+b);

}

}

}

3.RateMoney.java

import java.util.Scanner;

public class RateMoney {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

double money=0;

double rate=0;

System.out.print("請輸入?yún)R款金額:");

money=sc.nextDouble();

if(money0){

rate=0;

}

else if(money0money=100){

rate=1;

}else if(money100money=5000){

rate=money/100;

}else{

rate=50;

}

System.out.println("匯"+money+"元錢需匯款費:"+rate+"元");

}

}

三個都已經(jīng)寫出來了..

你好好看看吧!!

祝你早日成功!

急求JAVA小程序代碼(20分重賞)

try{

final int EOF = -1;

HashTable h = new HashTable();

Reader r = new FileReader(new File(args[0]));

int c = r.read();

while (c != EOF){

System.out.print((char)c); // 未作緩沖

Character key = new Character((char)c);

Object count = h.get(key);

if (count == null){count = new Integer(1);}

else {count = new Integer(((Integer)count).intValue + 1);}

h.put(key, count);

c = r.read();

}

}catch{...}

求JAVA大神給我發(fā)一段完整可運行的java圖形小程序的代碼(不用太多類),謝謝了

/*計算器*/

import java.awt.*;

import javax.swing.*;

import javax.swing.border.*;

import java.awt.event.*;

public class Calculator implements ActionListener{

JFrame frame;

JPanel panel;

JTextField tfShow;/*定義顯示文本框*/

JButton b1[]=new JButton[10]; /*數(shù)字按鈕*/

JButton b2[]=new JButton[6]; /*操作按鈕*/

boolean isNumber;/*判斷是否輸入多位數(shù)字的變量*/

double number;/*存儲輸入數(shù)值、顯示結(jié)果的變量*/

double result;/*存儲中間運算結(jié)果的變量*/

char operator;/*存儲當(dāng)前操作符的成員變量*/

public Calculator(){

frame=new JFrame("計算器");

frame.setSize(300,300);/*指定框架窗口的大小*/

frame.setResizable(false);/*使框架窗口不可改變大小*/

JPanel contentPane=(JPanel)frame.getContentPane();

contentPane.setBorder(new EmptyBorder(20,20,20,20));/*繪制框架的指定大小的空透明邊框*/

tfShow=new JTextField("0",25);/*指定屬性的文本域*/

tfShow.setHorizontalAlignment(JTextField.RIGHT);/*設(shè)置文本域中文本的對齊方式*/

isNumber=true;/*初始值設(shè)置*/

number=0;/*初始值設(shè)置*/

result=0;/*初始值設(shè)置*/

operator=' ';/*初始值設(shè)置*/

for(int i=0;ib1.length;i++){

b1[i]=new JButton(Integer.toString(i));/*創(chuàng)建數(shù)字按鈕*/

b1[i].setActionCommand(Integer.toString(i));

b1[i].addActionListener(this);

b1[i].setForeground(Color.blue);

}

String bs[]={"/","*","-","C","+","="};

for(int i=0;ib2.length;i++){

b2[i]=new JButton(bs[i]);/*創(chuàng)建操作按鈕*/

b2[i].setActionCommand(bs[i]);

b2[i].addActionListener(this);

b2[i].setForeground(Color.red);

}

panel=new JPanel();

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

panel.add(b1[1]);

panel.add(b1[2]);

panel.add(b1[3]);

panel.add(b2[0]);

panel.add(b1[4]);

panel.add(b1[5]);

panel.add(b1[6]);

panel.add(b2[1]);

panel.add(b1[7]);

panel.add(b1[8]);

panel.add(b1[9]);

panel.add(b2[2]);

panel.add(b1[0]);

panel.add(b2[3]);

panel.add(b2[4]);

panel.add(b2[5]);

frame.add(tfShow,BorderLayout.NORTH);/*將文本框放置在框架上方*/

frame.add(panel,BorderLayout.CENTER);/*將裝有按鈕組的panel放在框架的中心*/

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);/*設(shè)置框架窗口的默認(rèn)窗口關(guān)閉操作*/

frame.setVisible(true);/*設(shè)置框架可見*/

}

public double getDisplay(){/*返回要顯示的結(jié)果*/

return number;

}

public void reDisplay(){/*刷新文本域的內(nèi)容*/

tfShow.setText(""+getDisplay());

}

/*對輸入數(shù)字的處理*/

public void numberProcess(int num){

if(isNumbernum!=0){

String s1=Integer.toString(num);

String s2=Integer.toString((int)(this.number));

this.number=Double.parseDouble(s2+s1);/*對多位數(shù)字的處理*/

}else{

this.number=num;

}

isNumber=true;/*輸入連續(xù)數(shù)字(即多位數(shù)字)時為真*/

}?

public void operationProcess(char operator){/*根據(jù)輸入的操作符改變當(dāng)前操作符*/

switch(operator){

case '-':

this.operator='-';

break;

case '+':

this.operator='+';

break;

case '*':

this.operator='*';

break;

case '/':

this.operator='/';

break;

}

result=number;

isNumber=false;/*輸入操作符時表示輸入連續(xù)數(shù)字的標(biāo)記變量為假*/

}?

public void clear(){

number=0;

result=0;

}??

public void equal(){/*計算運算結(jié)果*/

switch(operator){

case '-':

result=result-number;

break;

case '+':

result=result+number;

break;

case '*':

result=result*number;

break;

case '/':

result=result/number;

break;

case ' ':

result=number;

break;

}

number=result; /*把運算結(jié)果賦值給顯示變量*/

isNumber=false;

operator=' ';?

}?

public static void main(String args[]){

Calculator cal=new Calculator();/*創(chuàng)建計算器*/

}

public void actionPerformed(ActionEvent e){

String command=e.getActionCommand();/*獲取按鈕激發(fā)的操作事件的命令名稱*/

char c=command.charAt(0);/*將按鈕命令名稱的第一個字符賦值給一個字符c*/

switch(c){

case '1':

case '2':

case '3':

case '4':

case '5':

case '6':

case '7':

case '8':

case '9':

case '0':

int number=Integer.parseInt(command);

numberProcess(number);/*輸入數(shù)字的處理*/

break;

case '+':

case '-':

case '*':

case '/':

operationProcess(c);/*算數(shù)運算符的處理*/

break;

case '=':equal();break;/*計算運算結(jié)果*/

case 'C':clear();break;/*清零*/

}

reDisplay(); /*在文本域中顯示信息*/

}

}

運行截圖:


網(wǎng)站欄目:java小程序代碼短 小程序代碼大小
文章地址:http://weahome.cn/article/hhdcds.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部