| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦   
共有 144 人关注过本帖
标题:怎么返回上一层?
收藏  订阅  推荐  打印
computerkimi
Rank: 1
来自:江西
等级:新手上路
帖子:20
积分:320
注册:2008-8-16
怎么返回上一层?

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("输入有误!请重新输入!");
                }
                
            }        
        }
        
}
2008-8-29 17:24
dcuzhang
Rank: 1
等级:新手上路
帖子:20
积分:318
注册:2008-3-13

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-8-29 21:19
meteor57
Rank: 3Rank: 3
来自:银河系
等级:中级会员
帖子:269
积分:3438
注册:2007-9-29

"让它第四次的时候重新输入,并且输入次数有限为三!"
看不懂...
有限为三,怎么还有第四次重新输入?
2008-8-30 20:00
共有 143 人关注过本帖
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.126176 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved