File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -11,12 +11,38 @@ public static double calculateSquare(double side) {
11
11
return area ;
12
12
}
13
13
14
+ public static void swap (int a , int b ) {
15
+ //swap
16
+ int temp = a ;
17
+ a = b ;
18
+ b = temp ;
19
+ System .out .println ("a=" + a );
20
+ System .out .println ("b=" + b );
21
+ }
22
+
23
+ public static int findProduct (int a , int b ) {
24
+ int product = a * b ;
25
+ return product ;
26
+ }
27
+
28
+ public static int findFactorial (int n ){
29
+ int fact =1 ;
30
+
31
+ for (int i =1 ;i <=n ;i ++){
32
+ fact *=i ;
33
+ }
34
+ return fact ;
35
+ }
36
+
14
37
public static void main (String [] args ) {
15
38
Scanner scanner = new Scanner (System .in );
16
39
System .out .println ("Enter side of a square" );
17
40
double side = scanner .nextDouble ();
18
41
printHelloWorld ();
19
42
double area = calculateSquare (side );
20
43
System .out .println ("The area of square is: " + area );
44
+ swap (1 , 2 );
45
+ System .out .println (findProduct (2 , 3 ));
46
+ System .out .println (findFactorial (3 ));
21
47
}
22
48
}
You can’t perform that action at this time.
0 commit comments