?? tax.java
字號:
package demo;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Tax extends HttpServlet{
protected void service(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,IOException{
String num = req.getParameter("num");
PrintWriter out = resp.getWriter();
try{
double income = Double.parseDouble(num);
double tax = 0.0;
double amount = income - 1600;
if(amount>0){
if(amount<=500){
tax = amount*0.05;
}else if(amount<=2000){
tax = 25 + (amount-500)*0.1;
}else if(amount<=5000){
tax = 175 + (amount-2000)*0.15;
}else if(amount<=20000){
tax = 625 + (amount-5000)*0.2;
}else if(amount<=40000){
tax = 3650 + (amount-20000)*0.25;
}else if(amount<=60000){
tax = 8650 + (amount-40000)*0.3;
}else if(amount<=80000){
tax = 14650 + (amount-60000)*0.35;
}else if(amount<=100000){
tax = 21650 + (amount-80000)*0.4;
}else{
tax = 29650 + (amount-100000)*0.45;
}
}
out.println("Income:"+num+" tax:"+tax);
}catch(NumberFormatException nfe){
out.println(num+" is invalid!");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -