| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2567 人关注过本帖
标题:怎么返回上一层?
只看楼主 加入收藏
computerkimi
Rank: 1
来 自:江西
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-8-16
收藏
 问题点数:0 回复次数:2 
怎么返回上一层?
import java.util.*;
    public class test{
        public static void main(String[] args){
            System.out.println("请按提示输入!");
            System.out.println("1、查询余额2、取款3、转账、4、退出取卡");
            Scanner input=new Scanner(System.in);
            int money=input.nextInt();

            //想在这里加个循环,让它第四次的时候重新输入,并且输入次数有限为三!怎么做?
                switch(money){
            
                    
                    case 1:
                        System.out.println("这是500元,请收好!");
                                                    
                            
                        break;
                    case 2:
                        System.out.println("请输入要转账的金额:");
                        System.out.println("请输入要转账的账号:");
                        break;
                    case 3:
                        System.out.println("请将卡收好!");
                        break;
                    case 4:
                        System.out.println("输入有误!请重新输入!");
                }
                
            }        
        }
        
}
搜索更多相关主题的帖子: public import money 
2008-08-29 17:24
dcuzhang
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-3-13
收藏
得分:0 
public static void main(String[] args)
    {
        // TODO Auto-generated method stub
        boolean isContinue = true;
        int count = 0;
        while(isContinue && count < 3)
        {
            System.out.println("make your choice");
            int choice;
            read in choice here
            
            switch(choice)
            {
                case 1: ****;
                        break;
                case 2: ****;
                         break;
                case 3: ****;
                        break;
                case 4: ****;
                        break;
                default : should never reach here;
                          break;
            }
            
            String wantContinue;
            println("continue ?  yes or No")
            read in wantContinu;
            if("yes".equals(wantContinue.toLowerCase()))
            {
                isContinue = true;
                count++;
            }
            else if("no".equals(wantContinue.toLowerCase()))
            {
                isContinue = false;
            }
            else
            {
                println(wrong answer);
                exit(1);
            }
        }
    }
2008-08-29 21:19
meteor57
Rank: 1
来 自:银河系
等 级:新手上路
帖 子:267
专家分:0
注 册:2007-9-29
收藏
得分:0 
"让它第四次的时候重新输入,并且输入次数有限为三!"
看不懂...
有限为三,怎么还有第四次重新输入?
2008-08-30 20:00
快速回复:怎么返回上一层?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036803 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved