运行代码,浏览器输入链接localhost:8090/page

package mainimport ("fmt""log""net/http""strconv"
)// 向客户端写入这些数据,以便客户端可以填写文本并提交
var indexHTML = `<html>
<head><meta http-equiv="Content-type" content="text/html; charset=utf-8"><title>测试</title>
</head>
<body><form action="/page" method="post">月基本工资:<br><input name="monthpay" type="text"><br>个人养老保险税率:<input name="EN" type="text">  企业养老保险税率:<input name="EEN" type="text"><br>个人医疗保险税率:<input name="ME" type="text">  企业医疗保险税率:<input name="EME" type="text"><br>个人工伤保险税率:<input name="EM" type="text">  企业工伤保险税率:<input name="EEM" type="text"><br>个人生育保险税率:<input name="MA" type="text">  企业生育保险税率:<input name="EMA" type="text"><br>个人失业保险税率:<input name="UN" type="text">  企业失业保险税率:<input name="EUN" type="text"><br>个人公积金税率:&nbsp;&nbsp;&nbsp;<input name="AF" type="text">  企业公积金税率: &nbsp;&nbsp;&nbsp;<input name="AF" type="text"><br><input type="submit" value="提交"></form>
</body>
</html>`// 用于将页面重定向到主页
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>`// 处理主页请求
func index(w http.ResponseWriter, r *http.Request) {// 向客户端写入我们准备好的页面fmt.Fprintf(w, indexHTML)
}// 处理客户端提交的数据
func page(w http.ResponseWriter, r *http.Request) {//月基本工资var monthpay float64//月数var monthnum float64 = 12//养老保险//var EN float64var ratio_EN, Eratio_EN float64//医疗保险//var ME float64var ratio_ME, Eratio_ME float64//失业保险//var UN float64var ratio_UN, Eratio_UN float64//工伤保险//var EM float64var ratio_EM, Eratio_EM float64//生育保险//var MA float64var ratio_MA, Eratio_MA float64//公积金//var AF float64var ratio_AF, Eratio_AF float64//per个人所得税pertax个人所得税率,su速扣计算数var per,pertax,su float64// 我们规定必须通过 POST 提交数据if r.Method == "POST" {// 解析客户端请求的信息if err := r.ParseForm(); err != nil {log.Println(err)}// 获取客户端输入的内容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=0case monthpay>5000&&monthpay<=8000:pertax=0.03;su=0case monthpay>8000&&monthpay<=17000:pertax=0.1;su=210case monthpay>17000&&monthpay<=30000:pertax=0.2;su=1410case monthpay>30000&&monthpay<=40000:pertax=0.25;su=2660case monthpay>40000&&monthpay<=60000:pertax=0.3;su=4410case monthpay>60000&&monthpay<=85000:pertax=0.35;su=7160case monthpay>85000:pertax=0.45;su=15160}per=(monthpay-5000)*pertax-su//年基本工资YearBasePay := yearbasepay(monthpay, monthnum)fmt.Println(YearBasePay)//养老税后After_tax_endowment := tax_endowment(monthpay, ratio_EN/100)tax_Eendowment := tax_endowment(monthpay, Eratio_EN/100)//生育税后After_tax_maternity := tax_maternity(monthpay, ratio_MA/100)tax_Ematernity := tax_maternity(monthpay, Eratio_MA/100)//失业税后After_tax_unemployment := tax_unemployment(monthpay, ratio_UN/100)tax_Eunemployment := tax_unemployment(monthpay, Eratio_UN/100)//医疗税后After_tax_medical := tax_medical(monthpay, ratio_ME/100)tax_Emedical := tax_medical(monthpay, Eratio_ME/100)//工伤税后After_tax_employment_injury := tax_employment_injury(monthpay, ratio_EM/100)tax_Eemployment_injury := tax_employment_injury(monthpay, Eratio_EM/100)//公积金税后After_tax_accumulation_fund := tax_accumulation_fund(monthpay, ratio_AF/100)tax_Eaccumulation_fund := tax_accumulation_fund(monthpay, Eratio_AF/100)//税后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)// 将内容反馈给客户端fmt.Fprintf(w, "月基本工资 %f,你输入的内容是:%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,月税后工资:%f,企业缴纳金额:%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 {// 如果不是通过 POST 提交的数据,则将页面重定向到主页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)              // 设置访问的路由http.HandleFunc("/page", page)           // 设置访问的路由err := http.ListenAndServe(":8090", nil) // 设置监听的端口if err != nil {log.Fatal("ListenAndServe: ", err)}}func yearbasepay(monthbasepay float64, monthnum float64) float64 {YaerBasepay := monthbasepay * monthnumreturn YaerBasepay
}
func tax_endowment(monthpay, ratio_endowment_insurance float64) float64 {res := monthpay * ratio_endowment_insurancereturn res
}
func tax_medical(monthpay, ratio_medical_insurance float64) float64 {res := monthpay * ratio_medical_insurancereturn res
}
func tax_unemployment(monthpay, ratio_unemployment_insurance float64) float64 {res := monthpay * ratio_unemployment_insurancereturn res
}
func tax_maternity(monthpay, ratio_maternity_insurance float64) float64 {res := monthpay * ratio_maternity_insurancereturn res
}
func tax_accumulation_fund(monthpay, ratio_accumulation_fund float64) float64 {res := monthpay * ratio_accumulation_fundreturn res
}
func tax_employment_injury(monthpay, ratio_employment_injury float64) float64 {res := monthpay * ratio_employment_injuryreturn 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)-perreturn 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_injuryreturn res
}

golang实现一个带Web界面的五险一金计算器相关推荐

  1. python词云去除词_使用Python制作一个带GUI界面的词云自动生成工具(连载五)

    上一篇中我们介绍了自动生成词云工具(GUI)中数据清洗界面的实现过程(详解词云自动生成工具的数据清洗界面制作过程(连载四)),了解掌握了Grid.Pack混合布局的方法.本篇我们将讨论Python自动 ...

  2. python制作软件界面_使用Python制作一个带GUI界面的词云自动生成工具(一)

    在现实生活中你可能会遇到这种情况:想知道一篇论文中哪个词语最多,哪些词语最少(以此判断文章的主要内容):想知道一部小说中哪一个人物出现的次数最多(当然,出现次数最多的那个人也不一定是主脚):想知道一部 ...

  3. python编写的软件界面-用Python写一个带图形界面的文件压缩软件

    这又是一篇用Python写小软件系列,最近有点写上瘾了,文件压缩和解压我们在日常工作学习中会经常用到,比如winrar.快压.好压等压缩软件,猿人学用Python做个简易图形界面的压缩软件. 打开之后 ...

  4. python color属性_使用Python制作一个带GUI界面的词云自动生成工具(连载七)

    前几篇向大家介绍了词云自动生成工具(GUI)的详解GUI词云自动生成工具中词云属性设置界面的实现(连载六).通过前面内容我们基本构建出了词云自动生成工具的主要框架.本篇结合tkinter中的filed ...

  5. 用c++写出带交互界面的简单计算器

    利用devc++和QT写交互界面的计算器 一.先下载一个QT 下载地址 http://download.qt.io/archive/qt/ 我下载的是 5.12.8 版本的 第四个是windos的 第 ...

  6. python使用爬虫写一个自己的翻译器(带图像界面)

    python使用爬虫写一个自己的翻译器(带图像界面)   大家好,我叫亓官劼(qí guān jié ),在CSDN中记录学习的点滴历程,时光荏苒,未来可期,加油~博客地址为:亓官劼的博客,B站昵称为 ...

  7. 写了一个puppet web 管理界面,打算开源

    2019独角兽企业重金招聘Python工程师标准>>> 写了一个puppet web 管理界面,打算开源 大家觉得怎么样 ? 转载于:https://my.oschina.net/u ...

  8. Delphi做的一个仿Web的导航界面

    完全原生开发,没有使用任何第三方组件,delphi 也是可以做出很精美的界面的. 使用Frame 来实现,实际上很多复杂的界面都可以使用Frame来组合设计,开发复杂界面必备的技术. DelphiWe ...

  9. 一个智能的 Web 界面测试系统

    一个智能的 Web 界面测试系统 2011年01月05日 本文内容包括: Web2.0 技术使 Web 界面更加丰富多彩,使信息交流更加灵活,同时也使得相关的 Web 技术测试需求越来越多.那么,如何 ...

最新文章

  1. 比较python类的两个instance(对象) 是否相等
  2. 毕业设计,步进电机解魔方机器人
  3. 指针常量和常量指针的区别
  4. 数学女孩儿中的数列问题
  5. Spring - 事件监听机制 源码解析
  6. C#判断当前系统当前时区是否使用夏令时(夏时制)
  7. 郭靖大侠的IT为学之路
  8. Mysql -- 管理工具
  9. algorithm介绍
  10. 手动清除2345流氓主页小记录以及对过去的一些回忆
  11. xt6使用技巧_凯迪拉克XT6:这几个“驾驶技巧”并不省油
  12. 如何才能做一个淡定从容的人呢?
  13. checkbox选中和不选中 jqu_jquery checkbox怎么选中和不选中?
  14. Lwip协议详解(基于Lwip 2.1.0)UDP协议(未完待续)
  15. android 源码分析
  16. php递归处理数组,PHP递归实现无限分类数组处理
  17. PPT母版如何取消?
  18. Easypoi使用模板导出文档或excel表格详解
  19. zigbee路由杂谈
  20. PHP实现执行定时任务的几种思路详解

热门文章

  1. oracle orderby多个字段,Oracle的order by关键字
  2. python pexpect_探索 Pexpect,第 2 部分:Pexpect 的实例分析
  3. 利用QGIS生成动图
  4. Laravel后端接口使用mews/captcha验证码注册+登录流程讲解
  5. 香港举办首个轮椅花车巡游 特首冀提升香港通达程度
  6. Microsoft Office 2016安装教程
  7. 视频编辑软件中如何制作字幕末屏停留
  8. python用glob遍历文件_尝试使用glob遍历python中文件夹中的文件
  9. 图片 美化 python_GitHub 项目推荐:用深度学习让你的照片变得美丽
  10. Windows环境定期清理Oracle归档日志