zoukankan      html  css  js  c++  java
  • 例:进店买衣服案例

    public class Test {
        
            
        public static void main(String []args){
            int count=0;
            System.out.println("进入第一家店 ");
            for(int j=1;j<=3&0<5-count;j++){    
                System.out.println("服务员问:先生您买衣服吗? ");
                Scanner s1 =new Scanner(System.in);
                String s2 = s1.next();
                if(s2.equals("是")){
                    System.out.println("购买一件衣服成功");
                    count++;
                    System.out.println("买了几件衣服"+count);
            }    if(s2.equals("不是")){
                System.out.println("对不起不买了");
                break;
        }
            }
            
            
            System.out.println("进入第二家店 ");
            for(int b=1;b<=3&0<5-count;b++){
                
                System.out.println("服务员问:先生您买衣服吗? ");
                Scanner s1 =new Scanner(System.in);
                String s2 = s1.next();
                if(s2.equals("是")){
                    System.out.println("购买一件衣服成功");
                    count++;
                    System.out.println("买了几件衣服"+count);
            }     if(s2.equals("不是")){
                System.out.println("对不起不买了");
                       break;
            }
            
                }
            
            
            System.out.println("进入第三家店 ");
            for(int a=1;a<=3&0<5-count;a++){
                
                System.out.println("服务员问:先生您买衣服吗? ");
                Scanner s1 =new Scanner(System.in);
                String s2 = s1.next();
                if(s2.equals("是")){
                    System.out.println("购买一件衣服成功");
                    count++;
                    System.out.println("买了几件衣服"+count);
            }    if(s2.equals("不是")){
                System.out.println("对不起不买了");
                break;
            }
                }
            System.out.println(count);
            }
        }
  • 相关阅读:
    python面向对象编程(1)——基本概念,术语,self,构造器
    django-中间件
    集合
    深入字典
    django使用小贴士
    自动化发送微信
    django-模板继承
    SMTP发送邮件
    git的使用
    django-csrf攻击
  • 原文地址:https://www.cnblogs.com/fy02223y/p/7157452.html
Copyright © 2011-2022 走看看