{ "type": "code_options", "author": "csdn.net", "source": "solution.md", "exercise_id": "ec24de171a30438d807712d827454a63", "keywords": "数学运算", "title": "商品优惠计算器", "desc": [ { "content": "\n

商品优惠计算器\n使用if语句编程实现输入购货金额,输出实际付款金额。购货折扣率如下:\n购货金额≤500元 不打折\n500元<购货金额≤1000元 9折\n1000元<购货金额 8折

", "language": "markdown" } ], "answer": [ { "content": "", "language": "cpp" } ], "prepared": [ [ { "content": "", "language": "cpp" } ], [ { "content": "", "language": "cpp" } ], [ { "content": "", "language": "cpp" } ] ], "template": { "content": "#include \n#include \n#include \n#include \n#include \n#include \nint main()\n{\n\tfloat money=0.0;\n\tfloat pay=0.0;\n\tbool run = true;\n\twhile(run)\n\t{\n\t\tprintf(\"\\n请输入购货金额:\\n\");\n\t\tscanf(\"%f\", &money);\n\t\tif(money >1000)\n\t\t{\n\t\t\tpay=money*0.8;\n\t\t\tprintf(\"打八折,应付金额:%.2f\\n\",pay);\n\t\t}\n\t\telse if((money >500)&&(money <=1000))\n\t\t{\n\t\t\tpay=money*0.9;\n\t\t\tprintf(\"打九折,应付金额:%.2f\\n\",pay);\n\t\t}\n\t\telse if(money <=500)\n\t\t{\n\t\t\tprintf(\"不打折,应付金额:%.2f\\n\",money);\n\t\t}\n\t}\n\treturn 0;\n}", "language": "cpp" }, "node_id": "dailycode-9b2837c3037b460e9a6fef477307ca55", "license": "csdn.net", "created_at": 1637894160, "topic_link": "https://bbs.csdn.net/topics/600470151" }