回复:(merciless)刚学的JAVA老师就出这样的题目有奖...
Twice.java
import java.io.*;
public class Twice
{
public static void main(String []args)
{
new Twice();
}
public Twice()
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Boolean err = false;
double input = 0;
do{
System.out.println("请输入一个有效的数字");
err = false;
try
{
input = Double.parseDouble(in.readLine());
}catch(Exception e)
{
System.out.println("数字格式不正确");
err = true;
}
}while(err);
System.out.println("" + (input * 2));
}
}
无标题:
public class Person implements Runner
{
public String name;
public int high;
private String loverName;
public String getLoverName()
{
return loverName;
}
public void setLoverName(String name)
{
loverName = name;
}
public void Run()
{
System.out.println("Person is running.");
}
}
public class Student implements Runner
{
public String classNumber;
public void FightForFreedom()
{
setLoverName("Freedom");
System.out.println("Fight For " + getLoverName());
}
public void Run()
{
System.out.println("Student is running.");
}
}
public interface Runner
{
public void Run();
}
没测试
[此贴子已经被作者于2007-6-25 22:27:47编辑过]