Home  >  Article  >  Web Front-end  >  JavaScript implements supermarket checkout function code

JavaScript implements supermarket checkout function code

巴扎黑
巴扎黑Original
2018-05-22 16:11:594515browse

This article introduces you to the JS simulated supermarket simple checkout applet code through example code. It is very good and has reference value. Friends who need it can refer to it.

No more nonsense, just give it to Everyone has posted the code. The specific code is as follows:

 <script type="text/javascript">
 // 1.编写一个程序,计算增加后的工资。要求基本工资大于等于1000元,增加20%的工资;若小于1000元且大于等于800元,则增加15%,若小于800元,则增加10%工资。
 var basepay = parseInt(prompt("请输入您的工资:"));//初始工资
 var pay1 = basepay+(basepay*0.2);//大于等于1000元,增加20%的工资
 var pay2 = basepay+(basepay*0.15);//小于1000元且大于等于800元,增加15%的工资
 var pay3 = basepay+(basepay*0.1);//小于800元,增加10%的工资
     if(basepay>=1000){
      document.write("您的总工资为:"+pay1+"元");
     }else if(800<=basepay&&basepay<1000){
      document.write("您的总工资为:"+pay2+"元");
     }else{
     document.write("您的总工资为:"+pay3+"元");
     }
</script>

The above is the detailed content of JavaScript implements supermarket checkout function code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn