-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay43_prob2.java
More file actions
72 lines (56 loc) · 1.84 KB
/
Day43_prob2.java
File metadata and controls
72 lines (56 loc) · 1.84 KB
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
62
63
64
65
66
67
68
69
70
71
72
/*
Rahul, Ramu and Ramesh where creating 3 different Function interface with multiple parameters, further Rahul did addition operation with multiple parameters, Ramu did multiplication operation with multiple parameters and Ramesh passed string message of the answers what Rahul and Ramu got in terms of words
Input Format
2 4
Constraints
Use 3 different types of functional interface for addition, multiplication operation with multiple parameters and one for passing the string message.
Use Only Lambda expression for addition, multiplication operations and passing the string message
Output Format
6
8
six eight
Sample Input 0
2 4
Sample Output 0
6
8
six eight
*/
// Kirtan Jain
import java.io.*;
import java.util.*;
interface Rahul {
int add(int a, int b);
}
interface Ramu {
int mul(int a, int b);
}
interface Ramesh {
String str(int a);
}
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int n=sc.nextInt(), m=sc.nextInt();
Rahul obj1 = (a,b)->{
return a+b;
};
int ans1=obj1.add(n, m);
Ramu obj2 = (a,b)->{
return a*b;
};
int ans2=obj2.mul(n, m);
Ramesh obj3 = (a)->{
String[] digits = new String[] {
"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine",
"ten","eleven","twelve","thirteen","fourteen",
"fifteen","sixteen","seventeen","eighteen", "nineteen"
};
return (digits[a]);
};
String s1=obj3.str(ans1),s2=obj3.str(ans2);
System.out.println(ans1+"\n"+ans2+"\n"+s1+" "+s2);
}
}