请高手用JAVA编程!谢谢!请高
全部给你写好了,都运行通过,个别类要求JDK在1。5以上,自己用的时候注意下:
1。
import javax。swing。JOptionPane;
public class Work1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
float sum = 0。 0f;
for(float i = 0。0f;ib?a:b;
intln(a+" , "+b+" 中较大的数是 "+c);
}
}
4。
public class Work4 {
public static void m...全部
全部给你写好了,都运行通过,个别类要求JDK在1。5以上,自己用的时候注意下:
1。
import javax。swing。JOptionPane;
public class Work1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
float sum = 0。
0f;
for(float i = 0。0f;ib?a:b;
intln(a+" , "+b+" 中较大的数是 "+c);
}
}
4。
public class Work4 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] list = {5,4,3,2,1};
intln("原数组:");
for(int i=0;i
length;i++) {
int(list[i]+",");
}
list = reverseArray(list);
intln("\n转换后的数组:");
for(int i=0;i
length;i++) {
int(list[i]+",");
}
}
public static int[] reverseArray(int [] list) {
int c = 0;
int last = list。
length -1;
for(int i=0;i
import java。util。Scanner;
public class Work5 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner( );
int []array = new int[10];
for(int i=0;i length;i++) {
intln("请输入第 "+(i+1)+" 个整数");
array[i] = xtInt();
}
array = reverseArray(array);
intln("你输入数据的逆序:");
array = reverseArray(array);
for(int i=0;i length;i++) {
int(array[i]+", ");
}
}
public static int[] reverseArray(int [] list) {
int c = 0;
int last = list。
length -1;
for(int i=0;i
import t。Graphics;
import javax。swing。JFrame;
public class Work6 extends JFrame {
public Work6() {
setSize(300,300);
setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Work6();
}
public void paint(Graphics g) {
int(g);
g。
drawString("Welcome to java!", 50, 170);
}
}
7。
import java。util。Scanner;
public class Work7 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner( );
intln("请输入字符串:");
String s = xt();
int last = s。
length() - 1;
boolean flag = true;
for(int i=0;i ");
flag = !flag;
break;
}
last--;
}
if(flag) {
intln("你输入的字符串是回文串。");
}
}
}
8。
import t。Button;
import t。Frame;
import t。event。ActionEvent;
import t。event。ActionListener;
public class Work8 extends Frame implements ActionListener {
private Button ok,cancle;
public Work8() {
ok = new Button("OK");
cancle = new Button("cancle");
dActionListener(this);
dActionListener(this);
add(ok,"North");
add(cancle,"South");
pack();
setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Work8();
}
public void actionPerformed(ActionEvent e) {
Button b = (Button) tSource();
if(b。
equals(ok)) {
intln("OK button is Clicked");
}
else {
intln("cancle button is Clicked");
}
}
}。
收起