-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfact.java
More file actions
46 lines (44 loc) · 870 Bytes
/
Copy pathfact.java
File metadata and controls
46 lines (44 loc) · 870 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
import java.util.Scanner;
class Factorial1
{
int n;
void getvalue()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter the no");
n=sc.nextInt();
System.out.println("the sum of series"+n);
}
}
class Factorial2 extends Factorial1
{
int calculate()
{
int fact=1;
for (int i=1;i<=n;i++)
{
fact =fact*i;
}
return fact;
}
}
class display extends Factorial1
{
void print_fn(int num)
{
System.out.println("the sum of series"+num);
}
}
public class fact
{
public static void main(String args[])
{
int sum;
Scanner sc=new Scanner(System.in);
Factorial2 f=new Factorial2();
f.getvalue();
sum=f.calculate();
display d=new display();
d.print_fn(sum);
}
}