当前位置:网站首页>Golang implements a five insurance and one gold calculator with web interface
Golang implements a five insurance and one gold calculator with web interface
2022-04-23 12:56:00 【Play ha ha 527】
Run code , Browser input link localhost:8090/page
package main
import (
"fmt"
"log"
"net/http"
"strconv"
)
// Write this data to the client , So that the client can fill in the text and submit
var indexHTML = `<html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title> test </title> </head> <body> <form action="/page" method="post"> Basic monthly wage :<br> <input name="monthpay" type="text"><br> Personal endowment insurance tax rate :<input name="EN" type="text"> Enterprise endowment insurance tax rate :<input name="EEN" type="text"><br> Personal medical insurance tax rate :<input name="ME" type="text"> Enterprise medical insurance tax rate :<input name="EME" type="text"><br> Personal injury insurance tax rate :<input name="EM" type="text"> Enterprise industrial injury insurance tax rate :<input name="EEM" type="text"><br> Personal maternity insurance tax rate :<input name="MA" type="text"> Enterprise maternity insurance tax rate :<input name="EMA" type="text"><br> Personal unemployment insurance tax rate :<input name="UN" type="text"> Enterprise unemployment insurance tax rate :<input name="EUN" type="text"><br> Personal provident fund tax rate : <input name="AF" type="text"> Enterprise provident fund tax rate : <input name="AF" type="text"><br> <input type="submit" value=" Submit "> </form> </body> </html>`
// Used to redirect the page to the home page
var redirectHTML = `<html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <meta http-equiv="Refresh" content="0; url={
{.}}"> </head> <body></body> </html>`
// Process home page requests
func index(w http.ResponseWriter, r *http.Request) {
// Write the prepared page to the client
fmt.Fprintf(w, indexHTML)
}
// Process the data submitted by the client
func page(w http.ResponseWriter, r *http.Request) {
// Basic monthly wage
var monthpay float64
// Monthly number
var monthnum float64 = 12
// endowment insurance
//var EN float64
var ratio_EN, Eratio_EN float64
// Medical insurance
//var ME float64
var ratio_ME, Eratio_ME float64
// unemployment insurance
//var UN float64
var ratio_UN, Eratio_UN float64
// employment injury insurance
//var EM float64
var ratio_EM, Eratio_EM float64
// maternity insurance
//var MA float64
var ratio_MA, Eratio_MA float64
// Accumulation fund
//var AF float64
var ratio_AF, Eratio_AF float64
//per Individual income tax pertax Personal income tax rate ,su Quick deduction calculation number
var per,pertax,su float64
// We stipulate that we must pass POST Submit data
if r.Method == "POST" {
// Parse the information requested by the client
if err := r.ParseForm(); err != nil {
log.Println(err)
}
// Get the content entered by the client
ENS := r.Form.Get("EN")
EMS := r.Form.Get("EM")
UNS := r.Form.Get("UN")
MAS := r.Form.Get("MA")
AFS := r.Form.Get("AF")
MES := r.Form.Get("ME")
monthpayS := r.Form.Get("monthpay")
EENS := r.Form.Get("EEN")
EEMS := r.Form.Get("EEM")
EUNS := r.Form.Get("EUN")
EMAS := r.Form.Get("EMA")
EAFS := r.Form.Get("EAF")
EMES := r.Form.Get("EME")
//userText := r.Form.Get("usertext")
ratio_EN, _ = strconv.ParseFloat(ENS, 64)
ratio_EM, _ = strconv.ParseFloat(EMS, 64)
ratio_UN, _ = strconv.ParseFloat(UNS, 64)
ratio_MA, _ = strconv.ParseFloat(MAS, 64)
ratio_AF, _ = strconv.ParseFloat(AFS, 64)
ratio_ME, _ = strconv.ParseFloat(MES, 64)
monthpay, _ = strconv.ParseFloat(monthpayS, 64)
Eratio_EN, _ = strconv.ParseFloat(EENS, 64)
Eratio_EM, _ = strconv.ParseFloat(EEMS, 64)
Eratio_UN, _ = strconv.ParseFloat(EUNS, 64)
Eratio_MA, _ = strconv.ParseFloat(EMAS, 64)
Eratio_AF, _ = strconv.ParseFloat(EAFS, 64)
Eratio_ME, _ = strconv.ParseFloat(EMES, 64)
switch{
case monthpay<=5000:pertax=0;su=0
case monthpay>5000&&monthpay<=8000:pertax=0.03;su=0
case monthpay>8000&&monthpay<=17000:pertax=0.1;su=210
case monthpay>17000&&monthpay<=30000:pertax=0.2;su=1410
case monthpay>30000&&monthpay<=40000:pertax=0.25;su=2660
case monthpay>40000&&monthpay<=60000:pertax=0.3;su=4410
case monthpay>60000&&monthpay<=85000:pertax=0.35;su=7160
case monthpay>85000:pertax=0.45;su=15160
}
per=(monthpay-5000)*pertax-su
// Annual basic wage
YearBasePay := yearbasepay(monthpay, monthnum)
fmt.Println(YearBasePay)
// After pension tax
After_tax_endowment := tax_endowment(monthpay, ratio_EN/100)
tax_Eendowment := tax_endowment(monthpay, Eratio_EN/100)
// Birth tax
After_tax_maternity := tax_maternity(monthpay, ratio_MA/100)
tax_Ematernity := tax_maternity(monthpay, Eratio_MA/100)
// After unemployment tax
After_tax_unemployment := tax_unemployment(monthpay, ratio_UN/100)
tax_Eunemployment := tax_unemployment(monthpay, Eratio_UN/100)
// After medical tax
After_tax_medical := tax_medical(monthpay, ratio_ME/100)
tax_Emedical := tax_medical(monthpay, Eratio_ME/100)
// After work-related injury tax
After_tax_employment_injury := tax_employment_injury(monthpay, ratio_EM/100)
tax_Eemployment_injury := tax_employment_injury(monthpay, Eratio_EM/100)
// Provident fund after tax
After_tax_accumulation_fund := tax_accumulation_fund(monthpay, ratio_AF/100)
tax_Eaccumulation_fund := tax_accumulation_fund(monthpay, Eratio_AF/100)
// After tax
After_taxmonth := After_tax_month(monthpay, After_tax_accumulation_fund, After_tax_endowment, After_tax_maternity, After_tax_unemployment, After_tax_medical, After_tax_employment_injury,per)
//After_tax_year:=YearBasePay-(After_tax_accumulation_fund+After_tax_endowment+After_tax_maternity+After_tax_unemployment+After_tax_medical+After_tax_employment_injury)
E_tax:=Etax(tax_Eaccumulation_fund, tax_Eendowment, tax_Ematernity, tax_Eunemployment, tax_Emedical, tax_Eemployment_injury)
fmt.Println(After_taxmonth)
// Feed back the content to the client
fmt.Fprintf(w, " Basic monthly wage %f, What you input is :%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f, Monthly after tax salary :%f, The amount paid by the enterprise :%f",
monthpay, ratio_EN, Eratio_EN, ratio_ME, Eratio_ME, ratio_EM, Eratio_EM, ratio_MA, Eratio_MA, ratio_UN, Eratio_UN, ratio_AF, Eratio_AF, After_taxmonth,E_tax)
} else {
// If not through POST Data submitted , Redirect the page to the home page
fmt.Fprintf(w, redirectHTML)
}
}
func main() {
//ROUND(MAX((Q5-5000)*{0.03;0.1;0.2;0.25;0.3;0.35;0.45}-{0;210;1410;2660;4410;7160;15160},0),2)
http.HandleFunc("/", index) // Set the route to access
http.HandleFunc("/page", page) // Set the route to access
err := http.ListenAndServe(":8090", nil) // Set the listening port
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
func yearbasepay(monthbasepay float64, monthnum float64) float64 {
YaerBasepay := monthbasepay * monthnum
return YaerBasepay
}
func tax_endowment(monthpay, ratio_endowment_insurance float64) float64 {
res := monthpay * ratio_endowment_insurance
return res
}
func tax_medical(monthpay, ratio_medical_insurance float64) float64 {
res := monthpay * ratio_medical_insurance
return res
}
func tax_unemployment(monthpay, ratio_unemployment_insurance float64) float64 {
res := monthpay * ratio_unemployment_insurance
return res
}
func tax_maternity(monthpay, ratio_maternity_insurance float64) float64 {
res := monthpay * ratio_maternity_insurance
return res
}
func tax_accumulation_fund(monthpay, ratio_accumulation_fund float64) float64 {
res := monthpay * ratio_accumulation_fund
return res
}
func tax_employment_injury(monthpay, ratio_employment_injury float64) float64 {
res := monthpay * ratio_employment_injury
return res
}
func After_tax_month(monthpay, tax_accumulation_fund, tax_endowment, tax_maternity, tax_unemployment, tax_medical, tax_employment_injury,per float64) float64 {
res := monthpay - (tax_accumulation_fund + tax_endowment + tax_maternity + tax_unemployment + tax_medical + tax_employment_injury)-per
return res
}
func Etax(tax_Eaccumulation_fund, tax_Eendowment, tax_Ematernity, tax_Eunemployment, tax_Emedical, tax_Eemployment_injury float64) float64 {
res := tax_Eaccumulation_fund + tax_Eendowment + tax_Ematernity + tax_Eunemployment + tax_Emedical + tax_Eemployment_injury
return res
}
版权声明
本文为[Play ha ha 527]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230615231181.html
边栏推荐
- 0基础可以考CPDA数据分析师证书吗
- RT-thread中关键词解释及部分API
- At instruction of nbiot
- SSM框架系列——注解开发day2-2
- Unable to create servlet under SRC subfile of idea
- C#,二维贝塞尔拟合曲线(Bézier Curve)参数点的计算代码
- 梳理网络IP代理的几大用途
- World Book Day: I'd like to recommend these books
- 21 days learning mongodb notes
- Summary of JVM knowledge points - continuously updated
猜你喜欢

实现一个盒子在父盒子中水平垂直居中的几种“姿势”

有趣的IDEA插件推荐,给你的开发工作增添色彩

教你快速开发一个 狼人杀微信小程序(附源码)

Try the server for one month for free, and attach the tutorial

【csnote】ER图

Please help me see what this is, mysql5 5. Thanks

数据库中的日期时间类型

leetcode:437. 路径总和 III【dfs 选还是不选?】

Software testing weekly (issue 68): the best way to solve difficult problems is to wait and see the changes and push the boat with the current.

98. Error s.e.errormvcautoconfiguration $staticview reported by freemaker framework: cannot render error page for request
随机推荐
Fashion cloud learning - input attribute summary
If you were a golang interviewer, what questions would you ask?
XinChaCha Trust SSL Organization Validated
CVPR 2022 & ntire 2022 | the first transformer for hyperspectral image reconstruction
Kubernetes 入门教程
Introduction to servlet listener & filter
Buuctf Web [gxyctf2019] no dolls
leetcode-791. Custom string sorting
SSM框架系列——数据源配置day2-1
Date time type in database
0基础可以考CPDA数据分析师证书吗
Synchronously update the newly added and edited data to the list
甲辰篇 創世紀《「內元宇宙」聯載》
Free and open source intelligent charging pile SaaS cloud platform of Internet of things
RT-thread中关键词解释及部分API
SSM framework series - annotation development day2-2
Packet capturing and sorting -- TCP protocol [8]
Customize the shortcut options in El date picker, and dynamically set the disabled date
5 free audio material websites, recommended collection
Record the problems encountered in using v-print