商店管理系统(顾客用)(初版)

这边写一点小小的商店管理系统,目前暂时只有几个功能,之后的博客中会进行改进,现在先将就着看吧。而且写的都是一些很基础的东西,就算新手应该也看得懂

这边附上代码

import java.util.Scanner;
public class shop{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        System.out.println("welcome to our shop!");
        System.out.println("press 1 to continue");
        System.out.println("press 2 to over");
        //判断进入或退出系统
        while(true)
        {
            int a = in.nextInt();
            if(a==2)
            {
                System.out.println("see you next time!");
                break;
                //退出循环
            }
            if(a!=1&&a!=2)
            {
                System.out.println("no found");
                //不会退出循环,所以必须输入正确的指令才能进行下一步
            }
            if(a==1)
            {
                System.out.println("there are many kinds of objects");
                System.out.println("press 1 and turn to vegetable");
                System.out.println("press 2 and turn to fruit");
                //商品的分类与进入
                int b = in.nextInt();
                if(b==1)
                {
                    System.out.println("No1 is tomato and just cost 6$");
                    System.out.println("No2 is potato and just cost 8$");
                    System.out.println("if you want to buy,please enter zhe number of them in proper order though the number is zero.");
                    //商品信息与购买格式
                    int Numbertomato = in.nextInt();
                    int Numberpotato = in.nextInt();
                    System.out.printf("you buy %d tomato and cost %d$\n",Numbertomato,6*Numbertomato);
                    System.out.printf("you buy %d potato and cost %d$",Numberpotato,8*Numberpotato);
                    //购买总数及价格
                    break;
                }
                if(b==2)
                {
                    System.out.println("No1 apple and just cost 10$");
                    System.out.println("No2 banana and just cost 4$");
                    System.out.println("if you want to buy,please enter zhe number of them in proper order though the number is zero.");
                    int Numberapple = in.nextInt();
                    int Numberbanana = in.nextInt();
                    System.out.printf("you buy %d apple and cost %d$\n",Numberapple,10*Numberapple);
                    System.out.printf("you buy %d banana and cost %d$",Numberbanana,4*Numberbanana);
                    break;
                }
            }
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值