1 Scanner a = new Scanner(System.in); 2 System.out.println("请输入您的分数"); 3 int fen = a.nextInt(); 4 if( fen >= 90 && fen <= 100) 5 { 6 System.out.println("您的成绩为A"); 7 } 8 else if( 90 > fen && fen >= 60) 9 { 10 System.out.println("您的成绩为B"); 11 } 12 else if ( fen < 60) 13 { 14 System.out.println("您的成绩为C"); 15 } 16 else 17 { 18 System.out.println("请您输入正确的分数"); 19 }
1 //题目二 求s=a+aa+aaa+aaaa+aa...a的值 2 3 Scanner b = new Scanner(System.in); 4 Scanner c = new Scanner(System.in); 5 System.out.println("请输出a的值"); 6 System.out.println("请输入相加的次数"); 7 int zi = b.nextInt(); 8 int cishu = c.nextInt(); 9 int sum = 1; 10 int s = 0 ; 11 for(int i = 1 ; i <= cishu ; i++) 12 { 13 if(i==1) 14 { 15 sum= 1; 16 } 17 else 18 { 19 sum=sum*10+1; 20 } 21 s = s +zi *sum; 22 } 23 System.out.println(s);
1 //题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半; 2 //再落下,求它在第10次落地时,共经过多少米?第10次反弹多高? 3 4 double g = 100.0; 5 double ci = 0 ; 6 7 for( int i = 1; i<=10;i++) 8 { 9 System.out.println("第"+i+"次落地经历了"+(ci*2+100)+"米"); if(i==10) 10 { 11 System.out.println("第十次的反弹高度是"+g); 12 } 13 g= g/2; 14 ci= ci+ g; 15 } 16 System.out.println("第10次落地经历了"+(ci*2+100)+"米"); 17