Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
67 lines (55 loc) · 1.18 KB

File metadata and controls

67 lines (55 loc) · 1.18 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package methods;
public class MethodTest {
public static void main(String[] args) {
// sum();
// printTable(9);
int s = getSumOf1to100();
System.out.println("Total sum : "+ s );
int x = findSmallestValue(19,10);
System.out.println("Smallest : "+ x );
}
// 1) no return type with no argument
static void sum() {
int a = 6;
int b = 9;
int c = a + b;
System.out.println("Result : "+ c);
}
// 2) no return type with argument
static void printTable(int n) {
for (int i =1; i<=10 ; i++) {
System.out.println(n+" x "+i+" = "+ (n*i));
}
}
// 3) return type with no argument
static int getSumOf1to100() {
int s = 0;
for (int i = 1; i<=100; i++) {
s = s + i;
}
return s;
}
// 4) return type with arguments
static int findSmallestValue(int x, int y) {
if(x<y) {
return x;
}
return y;
}
/*
* Q) find area and volumes as:
* a) getArea:
* -> pass l and b as a parameter
* -> calculate area
* -> return area
* -> call this method in main
*
* b) volume:
* -> pass area and height as parameter
* -> calculate volume
* -> print area
* -> print volume
* -> call this method in main
*
*/
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.