购物商店
import java.util.Scanner;
public class gowueasy {
public static void main(String[] args) {
Scanner ke = new Scanner(System.in);
System.out.println("欢迎来到云购物!!!");
System.out.println("**********************\n商品列表:\n1.巧克力\t2.红牛\t3.娃哈哈\n**********************");
String YN = "y";
float money;
float zmoney = 0.0f;
int num;
int znumone = 0, znumtwo = 0, znumthree = 0, zznum = 0;
String name = "";
String zname = "";
while (YN.equals("y")) {
System.out.println("请输入产品编号:");
int a = ke.nextInt();
switch (a) {
case 1:
name = "士虎";
money = 1.1f;
System.out.println("请选择购买的数量:");
num = ke.nextInt();
znumone += num;
zmoney += money * num;
zname += name + znumone + "\t";
break;
case 2:
name = "黑牛";
money = 2.2f;
System.out.println("请选择购买的数量:");
num = ke.nextInt();
znumtwo += num;
zmoney += money * num;
zname += name + znumtwo + "\t";
break;
case 3:
name = "雷碧";
money = 3.3f;
System.out.println("请选择购买的数量:");
num = ke.nextInt()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46