当前位置:网站首页>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
边栏推荐
- Labels and paths
- 【蓝桥杯】4月17日省赛刷题训练(前3道题)
- 使用Source Insight查看编辑源代码
- BaseRecyclerViewAdapterHelper 实现下拉刷新和上拉加载
- BUUCTF WEB [GXYCTF2019]禁止套娃
- Introduction to metalama 4 Use fabric to manipulate items or namespaces
- Free and open source charging pile Internet of things cloud platform
- 网站首页文件被攻击篡改的形式有哪些
- 梳理网络IP代理的几大用途
- Unlock openharmony technology day! The annual event is about to open!
猜你喜欢
Kubernetes 入门教程
CVPR 2022&NTIRE 2022|首个用于高光谱图像重建的 Transformer
4.DRF 权限&访问频率&过滤&排序
0基础可以考CPDA数据分析师证书吗
Embrace the new blue ocean of machine vision and hope to open a new "Ji" encounter for the development of digital economy
Free and open source charging pile Internet of things cloud platform
在线计算过往日期天数,计算活了多少天
Introduction to kubernetes
Resolve disagrees about version of symbol device_ create
Can I take the CPDA data analyst certificate for 0 foundation
随机推荐
unity常见的问题(一)
Packet capturing and sorting -- TCP protocol [8]
梳理網絡IP代理的幾大用途
Buuctf Web [gxyctf2019] no dolls
【蓝桥杯】4月17日省赛刷题训练(前3道题)
Fashion cloud learning - input attribute summary
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.
Redis deployment of cloud native kubesphere
NPDP|产品经理如何做到不会被程序员排斥?
Plato farm - a game of farm metauniverse with Plato as the goal
在线计算过往日期天数,计算活了多少天
Zero trust in network information security
航芯技术分享 | ACM32 MCU安全特性概述
Kubernets Getting started tutoriel
Labels and paths
Homomorphic encryption technology learning
教你快速开发一个 狼人杀微信小程序(附源码)
leetcode:437. Path sum III [DFS selected or not selected?]
SSM framework series - JUnit unit test optimization day2-3
Introduction to servlet listener & filter