请输入密码及确认密码,如果两次密码不一致,则重新输入,直至密码一致,输出“密码设置成功”String pwd1 = "";//pwd1存储密码String pwd2 = "";//pwd2存储确认密码Scanner sc =new Scanner(System.in);do{System.out.println("请输入密码:");pwd1=____;System.out.println("请再次输入密码:");pwd2=____;} while(____);System.out.println("密码设置成功!");
查看答案
计算1+2+3+…100。int i = 1;//存储项int sum = 0;//存储和 do{____;____;} whil (i <= 100);System.out.println("和为:" + sum);
1. 已知本金为1000元,年利率为3.5%,试求存入银行多少年后本利和翻一番。____money = 1000;int year =0;while ( money<2000 ){____; money = money + money * 0.035;} System.out.println("需要" + year + "年");
设有一张厚为0.2 mm,面积足够大的纸,将它不断地对折。试问对折多少次后,其厚度可达20m。 double thickness = 0.2; int count = 0; while(____) {thickness ____;____; } System.out.println("次数为" + count);
从1开始做自然数的累加,当其累加和大于等于500时,共计累加了多少数?当时的累加和是多少? int num = 0; int sum = 0; do {num++;sum____; } while(____); System.out.println("累加了" + num + "次,和为" + sum);