java编手机小程序代码 如何java编程java小程序实例大全

急求小程序,用JAVA编写import java.util.Scanner;
public class NumberConvertor {
/**
* @param args
*/
public int input() {
Scanner scan = new Scanner(System.in);
int inputInt = 0;
while (true) {
try {
System.out.println("输入一个0-100的正整数(默认为0): ");
inputInt = scan.nextInt();
if (inputInt0 || inputInt = 100) {
System.out.println("越界");
continue;
} else {
break;
}
} catch (Exception e) {
System.out.println("输入有误,重新输入");
break;
}
}
return inputInt;
}
public String convert(int aInt) {
String[] table = new String[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒",
"捌", "玖", "拾" };
String result;
String left;
String right;
int leftInt;
int rightInt;
if (aInt = 10) {
result = table[aInt];
} else {
leftInt = Integer.parseInt((String.valueOf(aInt)).substring(0, 1));
rightInt = Integer.parseInt((String.valueOf(aInt)).substring(1));
left = table[leftInt];
right = table[rightInt];
result = left + table[10] + right;
}
return result;
}
public static void main(String[] args) {
NumberConvertor nc = new NumberConvertor();
int val;
val = nc.input();
System.out.println(nc.convert(val));
}
}
编写一个java小程序!public test_03(){
init();
}
public void init(){
JLabel jl_1=new JLabel("用户名");
JLabel jl_2=new JLabel("密码");
JTextField jtf=new JTextField();
JPasswordField jpf=new JPasswordField();
JButton button_1=new JButton("确定");
JPanel panel=new JPanel();
panel.setLayout(null);
jl_1.setBounds(30, 50, 50, 30);
jl_2.setBounds(30,90,50,30);
jtf.setBounds(100, 50, 100, 30);
jpf.setBounds(100, 90, 100, 30);
button_1.setBounds(110, 130, 80, 30);
panel.add(jl_1);
panel.add(jl_2);
panel.add(jtf);
panel.add(jpf);
panel.add(button_1);
this.add(panel);
this.setSize(300, 250);
this.setLocation(400, 300);
this.setVisible(true);
}
public static void main(String[] args) {
new test_03();
}
用JAVA编写一个小程序 , 不限类型好玩点的 。控制台小游戏 class YZDEL
{
public static void main(String[] args)
{
java.util.Random Shiji = new java.util.Random();
java.util.Scanner Shuru = new java.util.Scanner(System.in);
java.util.Scanner Nandu = new java.util.Scanner(System.in);
int YingxHP = 20;
int YingxMP = 0;
int MogHP = 20;
int MogMP = 0;
int MogDo = 0;
int fangyu = 0;
System.out.println("┏━━━━╮┏━━┣┣┓ ╮ ┓┏━┳━┳┓┓━┓ ");
System.out.println("┏┣━━━┓┏━━┣┣┓ ┃┏ ┃ ┃┓┃ ╯ ");
System.out.println("┣┣━━━┫╭━━┻╯╮ ┃╰┓┃ ┃╯┏━┣━━┓");
System.out.println("┣┣━━━┫┏━━━━┓╭━━┣━┛┗━┻━┻┛┃┃");
System.out.println("┏┣━━━┓┣━━━━┫ ┃┃┃┗╮╮┃┃┣━╯");
System.out.println(" ┛┗╯┗━━━━╯┗╯╰╰━━┛┛┗━╯╰━┛");
System.out.println();
System.out.println("作者:天狐空幻");
System.out.println();
System.out.println("说明:勇者的操作方式为以下所示:");
System.out.println("使用攻击需消耗1MP 伤害1HP");
System.out.println("使用蓄力可增加1MP 伤害0HP");
System.out.println("使用躲闪需消耗0MP 伤害0HP躲避攻击");
System.out.println("使用重击需消耗3MP 伤害2HP防御无效");
System.out.println("恶龙攻击力高,注意防御是取胜的关键");

推荐阅读