8000 First commit · aasys12/learningJava@6abef54 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6abef54

Browse files
committed
First commit
0 parents  commit 6abef54

File tree

5 files changed

+93
-0
lines changed

5 files changed

+93
-0
lines changed

src/returnMethodTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class returnMethodTest {
2+
public static void main(String[] args) {
3+
System.out.println("The grade is "+grade(93.0));
4+
}
5+
public static char grade(double Score){
6+
if(Score>=90){
7+
return 'A';
8+
}
9+
else if(Score>=80){
10+
return 'B';
11+
}
12+
else return 'F';
13+
}
14+
}

src/sum.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class sum {
2+
public static int add(int i1, int i2){
3+
4+
int result=0;
5+
for (int i = i1; i <i2 ; i++) {
6+
result += i;
7+
}
8+
return result;
9+
}
10+
11+
public static void main(String[] args) {
12+
System.out.println("Sum from 1 to 10 is "+ add(1,10));
13+
System.out.print("Sum from 1 to 10 is "+ add(20,30));
14+
}
15+
}

src/testMax.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
public class testMax {
2+
public static int max(int i1,int i2){
3+
int result;
4+
5+
6+
if(i1>i2){
7+
result=i1;
8+
}
9+
else
10+
result=i2;
11+
12+
return result;
13+
14+
}
15+
16+
public static void main(String[] args) {
17+
int a=5;
18+
int b=6;
19+
int c=max(a,b);
20+
System.out.println("The max is "+ c);
21+
}
22+
}

src/testMethodOverloading.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class testMethodOverloading {
2+
public static int max(int i, int j){
3+
if(i>j){
4+
return i;
5+
}
6+
else return j;
7+
}
8+
public static double max(double i, double j){
9+
if(i>j){
10+
return i;
11+
}
12+
else return j;
13+
}
14+
public static double max(double i, double j, double k){
15+
return max(max(i,j),k);
16+
}
17+
18+
public static void main(String[] args) {
19+
System.out.println("The max is "+max(5,10));
20+
System.out.println("The max is "+max(5.0,10.0));
21+
System.out.println("The max is "+max(5.0,10.0,4.0));
22+
}
23+
}

src/testVoidMethod.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class testVoidMethod {
2+
public static void Grade(double Score) {
3+
if (Score >= 90) {
4+
System.out.println("A");
5+
}
6+
else if (Score >= 80) {
7+
System.out.println(" B");
8+
} else
9+
System.out.println("F");
10+
11+
12+
}
13+
14+
public static void main(String[] args) {
15+
System.out.print("The grade is ");
16+
Grade(92.0);
17+
}
18+
}
19+

0 commit comments

Comments
 (0)
0