1 Star 0 Fork 0

姚鑫/第五章作业

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Code010.java 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
import java.util.Scanner;
public class Code010 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String name = "";
double price = 0.0;
int goodsNo = 0;
int amount = 0;
double discount = 0.8;
double total = 0.0;
double money = 0.0;
System.out.println("MyShopping 管理系统 > 购物结算\n");
System.out.println("*************************************************** **");
System.out.println("请选择购买的商品编号:");
System.out.println("1.T 恤\t\t2.网球鞋\t\t3.网球拍");
System.out.println("*************************************************** **\n");
String answer = "y";
while("y".equals(answer)){
System.out.print("请输入商品编号:");
goodsNo = input.nextInt();
System.out.print("请输入购买数量:");
amount = input.nextInt();
switch(goodsNo){
case 1:
name = "T 恤";
price = 245.0;
break;
case 2:
name = "网球鞋";
price = 570.0;
break;
case 3:
name = "网球拍";
price =320.0;
break;
}
total = price * amount;
System.out.println(name + "¥" + price + "\t" + "数量" + amount + "\t合计¥" + total);
System.out.println("是否继续(y/n)");
answer = input.next();
System.out.println();
money += total;
}
System.out.println("折扣:" + discount);
System.out.println("应付金额:" + (money * discount));
System.out.print("实付金额:");
double payment = input.nextDouble();
System.out.println("找钱:" + (payment - money * discount));
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/duojiu327/DiWuZhangZuoYe.git
[email protected]:duojiu327/DiWuZhangZuoYe.git
duojiu327
DiWuZhangZuoYe
第五章作业
master

搜索帮助