/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
float CarRental = 0;
float Sum = 0;
System.out.println("欢迎使用达达租车系统:");
System.out.println("您是否要租车:1:是 0:否");
Scanner input = new Scanner(System.in);
switch(input.nextInt()){
case 1:
String sql = "select * from tb_cargoods";
Result result = CarBaseDao.runSelect(sql);
if(result.getRowCount()>0){
Map[] rows = result.getRows();
List carList = new ArrayList();
for(Map row:rows){
int CarNo = Integer.parseInt(row.get("CarNo").toString());
//String CarNo = row.get("CarNo").toString();
String CarName = row.get("CarName").toString();
CarRental = Float.parseFloat(row.get("CarRental").toString());
//float CarCapacity = Float.parseFloat(row.get("CarCapacity").toString());
String CarCapacity = row.get("CarCapacity").toString();
//Car car = new Car(CarNo,CarName,CarRental,CarCapacity);
//carList.add(car);
carList.add(new Car(CarNo,CarName,CarRental,CarCapacity));
}
request.setAttribute("carList", carList);
request.getRequestDispatcher("showCar").forward(request, response);
System.out.println("请输入你要租汽车的数量:");
int CarNum = new Scanner(System.in).nextInt();
if(CarNum>0){
for(int i= 1;i<=CarNum;i++){
System.out.println("请输入第"+i+"辆车的序号");
Sum = Sum +CarRental;//一天租车的总金额
}
System.out.println("请输入租车的天数:");
int DayNum = new Scanner(System.in).nextInt();
Sum = DayNum*(Sum);//多天租车的总金额
}else{
System.out.println("您的输入有误");
}
}else{
System.out.print("没有商品显示");
}break;
case 0:
System.out.println("欢迎下次使用!");
break;
default:
System.out.println("输入有误");
}
}
添加回答
举报
0/150
提交
取消