java题目 高分求助(紧急)

2025-05-23 19:02:44
推荐回答(2个)
回答1:

1.i=5j=-3
2.4
3.2
4.int: 8
double: 8.0
5.Not Equal
6.SubClass: 200
SuperClass: 100
7.import java.util.Scanner;
public class TestMath {
public static void main(String[] args) {
double sum = 1;
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int i = 1;
while (i <= num) {
sum *= count(i);
i++;
}
System.out.println(sum);
}

static double count(int i) {
return Math.pow(2, i);
}
}
8.extends,super.test()
9.i=0
10. The value is 2
The value is 3

回答2:

1: 输出结果 i=5j=-3
2: 输出结果 4
3:输出结果 3
4:输出结果
int: 8
double: 8.0
5:输出结果 Not Equal
6:输出结果
SubClass: 200
SuperClass: 100

7 :public class TestSum{
public long sum(int number){
long s=1;
long k=1;;
for(long i=2;i<=number;i++){

if(i%k==0){
s*=i;
k=i;
}
}
return s;
}
public static void main(String[] args){
System.out.println(new TestSum().sum(12));
}

}

8:extends ,super.test()
9: 输出结果 i = 0
10: 输出结果
The value is 2
The value is 3