-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandLineProgram.java
More file actions
62 lines (44 loc) · 981 Bytes
/
Copy pathCommandLineProgram.java
File metadata and controls
62 lines (44 loc) · 981 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class FactorialModule
{
private int result;
private int value;
FactorialModule()
{}
FactorialModule(int x)//a constructor with one argument(parameterised constructor)
{
value = x;
result = 1;
}
void calculation()
{
for(int i=1; i<=value; i++)
{
result = result *i;
}
}
void display()
{
System.out.println("The factorial is " + result);
}
/* As this program first takes value from user then it will
* start to run that is why it is call command line program
* */
/* It will not run in eclipse.
* We have to run this using console
* */
}
class FactorialRun
{
public static void main(String a[])
{
int number1 = Integer.parseInt(a[0]);
int number2 = Integer.parseInt(a[1]);
FactorialModule fm1 = new FactorialModule(number1);
FactorialModule fm2 = new FactorialModule(number2);
FactorialModule fm3 = new FactorialModule();
fm1.calculation();
fm1.display();
fm2.calculation();
fm2.display();
}
}