JAVA版本
import javax.swing.JOptionPane;
public class Test {
/**记录用户的输入年*/
int inputNum;
public Test(){}
/**返回用户的输入*/
public int getYear()
{
return inputNum = Integer.parseInt(JOptionPane.showInputDialog(null,"input a number ,this number >=0"));
}
/**计算出相应面积*/
private int computer()
{
Test t = new Test();
int temp=t.getYear();
int result=300;
if(temp==0)
{
return result;
}
else if(temp==1)
{
result=305;
return result;
}
else if(temp>1)
{
for(int i=2;i<=temp;i++)
{
result=305+(1*(temp-1));
return result;
}
}
return result;
}
/**输出计算结果*/
public void outPut()
{
System.out.println("面积为:"+computer()+"公顷");
}
/**Main方法,程序的入口*/
public static void main(String[] args) {
// TODO: Add your code here
new Test().outPut();
}
}