1.
顺序语句练习
6
道题
.
方法
1
?/p>
.
数组
2
道。类
2
?/p>
建项?/p>
Test+
学号
每个题一个包
把每个项目压?/p>
专业班级学号姓名
提交
时间
3
小时
数组?/p>
做题号为偶数?/p>
去掉柜子
八皇?/p>
方法
?/p>
1 3 11 13 14 16
类:
1
5
4
6 7 8 9
14
15 16
异常?/p>
.
循环练习
public class lx5 {
public static void main(String args[]){
System.out.println("50
以内的素数:
");
System.out.print("2 "+"3 ");
int c=2;
for(int i=3;i<=100;i++)
for(int j=2;j<=(int)Math.sqrt(i);j++){
if(i%j==0)break;
if(j>=(int)Math.sqrt(i)){
System.out.print(i+" ");
c++;
if(c%10==0)
System.out.println();
}
}
}
}
6.
(统计正数和负数的个数然后计算这些数的平均值)编写程序,读入未指定个数的整数,
分别判断读入的正数和负数的个数,
然后计算这些输入值的总和及其平均?/p>
(不?/p>
0
计数?/p>
?/p>
当输入为
0
时候,表示程序结束。将平均值以浮点数的形式显示?/p>
?/p>
20
分)
下面是一个运行示例:
Enter an int value, the program exits if the input is 0:
1 2 -1 3 0
The number of positives is 3
The number of negatives is 1
The total is 5
The average is 1.25
7.(
财务程序
)
:假设某个大学今年的学费?/p>
10000
元,学费以每?/p>
5%
速度增加,编写程?