当前位置:网站首页>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
- AD20补充笔记3—快捷键+持续更新
- 精度、速度完美平衡,最新图像分割SOTA模型重磅发布!!!
- STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
- Common problems of unity (1)
- [vulnhub range] - DC2
- BUUCTF WEB [BJDCTF2020]The mystery of ip
- Introducing vant components on demand
- About the 'enum' enumeration type and structure.
- 产品开发都应该知道的8个网站,增强工作体验
猜你喜欢

如何防止网站被黑客入侵篡改

The El table horizontal scroll bar is fixed at the bottom of the visual window

Kubernetes 入門教程

Use compressorjs to compress pictures, optimize functions, and compress pictures in all formats

Introduction to metalama 4 Use fabric to manipulate items or namespaces

Introduction to servlet listener & filter

mysql中 innoDB执行过程分析

NPDP|产品经理如何做到不会被程序员排斥?

Process virtual address space partition

解决disagrees about version of symbol device_create
随机推荐
【csnote】ER图
BaseRecyclerViewAdapterHelper 实现下拉刷新和上拉加载
php生成json处理中文
After the data of El table is updated, the data in the page is not updated this$ Forceupdate() has no effect
Jiachen chapter Genesis "inner universe" joint Edition
leetcode:437. Path sum III [DFS selected or not selected?]
At instruction of nbiot
leetcode:437. 路径总和 III【dfs 选还是不选?】
梳理网络IP代理的几大用途
[csnote] ER diagram
BUUCTF WEB [BUUCTF 2018]Online Tool
使用Source Insight查看编辑源代码
[daily question] chessboard question
The El table horizontal scroll bar is fixed at the bottom of the visual window
22. Bracket generation
0基础可以考CPDA数据分析师证书吗
Softbank vision fund entered the Web3 security industry and led a new round of investment of US $60 million in certik
Record some NPM related problems (messy records)
BUUCTF WEB [BJDCTF2020]The mystery of ip
Embrace the new blue ocean of machine vision and hope to open a new "Ji" encounter for the development of digital economy