题目内容

计算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);

程序填空题:输入一个正整数,并做以下运算:如果为偶数,除以2;如果为奇数,乘3加1。得到的结果再按上述要求运算,直到最后的结果为1,经过多少次这样的运算才得到数1。 public ____Test {public ____void main(string[] args){System.out.println("请输入一个正整数:");Scanner sc=new Scanner(System.in);int num =;int count = 0;while (num != 1){if (____){ num = num / 2; } else { num=num*3+1; } ____; } System.out.println("次数为:" + count); } }

答案查题题库