-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp_loop.java
More file actions
33 lines (32 loc) · 990 Bytes
/
p_loop.java
File metadata and controls
33 lines (32 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// You are supposed to support method calling for testing this case.
// The minimum required would be calling a method with an empty parameter list and belongs to a class without instance variables.
class p_loop {
public static void main(String [] args) {
{
System.out.print("Factorial of 10 is:");
System.out.println(new Factorial().compute10());
}
}
}
// This test case tests while loop execution.
class Factorial {
public int compute10() {
int prod;
int multiplier;
int a;
int b;
multiplier = 1;
a = 2;
b = 4;
prod = 1;
while (multiplier <= 10) {
prod = prod * multiplier;
multiplier = multiplier + 1;
System.out.println(prod);
a = a * b;
System.out.println(a);
System.out.println(20 + 3 * 2 + 5 * 2 - 4 * 3 + 3 * 3 - 2 * 4);
}
return prod;
}
}