-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_ques_3.java
More file actions
41 lines (35 loc) · 1.11 KB
/
array_ques_3.java
File metadata and controls
41 lines (35 loc) · 1.11 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
import java.util.Scanner;
import javax.swing.text.FlowView.FlowStrategy;
public class array_ques_3 {
public static void main(String[] args) {
/*
* // practice
*
* // ques-1 creat a array a 5 floats and calculate their sum
* float[] marks = { 45.2f, 27.3f, 48.25f, 36.45f, 75.4f, 4587.24587f };
* float sum =0;
* for(float num:marks){
* sum=sum+num;
*
*
* System.out.println("the sum is\n"+ sum);
*/
boolean isinarray = false;
float[] marks = { 45.2f, 27.3f, 48.25f, 36.45f, 75.4f, 4587.24587f };
// float num = 27.457f;
Scanner sc=new Scanner(System.in);
int num = sc.nextInt();
for (float element : marks) {
if (element == num) {
isinarray = true;
break;
}
}
if(isinarray){
System.out.println("the element is in array");
}
else{
System.out.println("element is not in array");
}
}
}