一个出租车计费的小程序,通过了编译,但运行出错,请教各位高手!!!
/**
  * 出租车计费程序
  * 7:00到23:00之间,起价10元,在3公里以内收取起价,超过3公里,超出的里程每公里收取1.2元。
  * 如果不在这个时段,起价11元,在3公里以内收取起价,超过3公里,超出的里程每公里收取1.4元。
  * 编写程序计算收费金额。要求:可以从命令行输入公里数,在程序中使用Java中现有的类,自动获取
  * 系统时间,并将最终计算结果显示出来。
  */
import java.util.Calendar;
public class CalcTaxi
{
	static int len;//行驶公里数
	float startPrice;//起价
	float startLen=3;//默认起始里程
	float perPrice;//每公里价格
	float price;//总价
	/**
	 * @param args
	 */	
	public void  setPrice()
	{
		int currHour=Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
		if(currHour>=7&&currHour<=23)
		{
			startPrice=10;
			perPrice=1.2f;
		}
		else
		{
			startPrice=11;
			perPrice=1.4f;
		}
	}	
	public void calc(int len)
	{
		//this.len=len;
		setPrice();
		if(len<=startLen)
			price=startPrice;
		else  
			price=startPrice+perPrice*(len-startLen);
		price=(float)(Math.floor(price*100)/100);
		price=Math.round(price);
	}	
	public void show()
	{
		System.out.println("起价:"+startPrice);
		System.out.println("起始公里"+startLen);
		System.out.println("每公里价格"+perPrice);
		System.out.println("里程:"+len);
		System.out.println("===========================");
		System.out.println("总价:"+price);
	}	
	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		CalcTaxi ta1=new CalcTaxi();
		int len =0;		  
		try
		{
			len=Integer.parseInt(args[0]);
		}catch(
NumberFormatException ee)
		{
			System.out.println("请输入合法的公里数");
			System.out.println(ee);
			return ;
		}
		ta1.calc(len);
		ta1.show();
	}
}
------解决方案--------------------同意ls的意见,你的程序没有输入参数啊.可以用ls的方法或者加个system.in
------解决方案--------------------是不是这个异常
java.lang.ArrayIndexOutOfBoundsException??
是的话,1楼说得对了!