forked from eazybytes/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReturnStatementDemo.java
More file actions
31 lines (27 loc) · 836 Bytes
/
ReturnStatementDemo.java
File metadata and controls
31 lines (27 loc) · 836 Bytes
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
public class ReturnStatementDemo {
public static void main(String[] args) {
String result = getStudentGrade(90);
System.out.println(result);
int [] arrayOfInt = { 43, 455, 4376, 343, 6 };
int lookingFor = 455;
int index = findAndReturnNumber(arrayOfInt,lookingFor);
System.out.println(index);
}
public static String getStudentGrade ( int marks) {
String result;
if(marks>= 40) {
result = "Passed";
} else {
result = "Failed";
}
return result;
}
public static int findAndReturnNumber (int [] arrayOfNums , int target) {
for(int i =0;i<arrayOfNums.length;i++) {
if(arrayOfNums[i] == target){
return i;
}
}
return -1;
}
}