java让一句话显示三遍_用Java写的一个简单的帮助菜单程序,但是老是执行三遍不知道为什么,大家给看看,谢了哈^_^~...

判断语句也没错吧,可是如果输入(1-5)之外的任何字母或数字do-while循环都会执行三次不知道为什么,请教高手解答importjava.io.IOException;publicclassTestDoWhile{publicstaticvo...

判断语句也没错吧,可是如果输入(1-5)之外的任何字母或数字do-while循环都会执行三次不知道为什么,请教高手解答

import java.io.IOException;

public class TestDoWhile {

public static void main(String args[]) throws IOException{

char choice = 0 ;

do{

System.out.println("Help on:");

System.out.println("1.if");

System.out.println("2.switch");

System.out.println("3.while");

System.out.println("4.do-while");

System.out.println("5.for");

System.out.println("Choice one:");

choice=(char)System.in.read();

}while(choice'5');

System.out.println("******************");

switch(choice){

case'1':

System.out.println("The if:");

System.out.println("if(condition)statement;");

System.out.println("else statement");

break;

case'2':

System.out.println("The switch:");

System.out.println("switch(expression){");

System.out.println("case constant:");

System.out.println("statement sequence");

System.out.println("break;");

System.out.println("//...");

System.out.println("}");

break;

case'3':

System.out.println("The while:");

System.out.println("while(condition)"+"statement;");

break;

case'4':

System.out.println("The do-while:");

System.out.println("do{");

System.out.println("statement");

System.out.println("}while(condition);");

break;

case'5':

System.out.println("The for:");

System.out.println("for(int;condition;"+"iteration)");

System.out.println("statement;");

break;

}

}

}

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值