-
Notifications
You must be signed in to change notification settings - Fork 0
/
YT44.java
59 lines (47 loc) · 1.08 KB
/
YT44.java
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
//overloading- return type
public class YT44
{
public double perform(double r, double h)
{
double l= Math.sqrt((r*r) + (h*h));
double csa = 3.14*r*l;
return csa;
}
public void perform(int r, int c)
{
int n=1;
for(int i=1; i<=r; i++)
{
for(int j=1; j<=c; j++)
{
System.out.print(n);
n++;
}
System.out.println();
n=1;
}
}
public void perform(int m, int n, char ch)
{
if(ch=='Q')
{
System.out.println(m/n);
}
else if(ch=='R')
{
System.out.println(m%n);
}
else
{
System.out.println("Wrong Input: Type Q or R");
}
}
public static void main(String[] args)
{
YT44 y1 = new YT44();
double d= y1.perform(2.5, 3.5);
System.out.println(d);
y1.perform(4, 5);
y1.perform(10, 6, 'Q');
}
}