-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFiveNumber.java
More file actions
104 lines (70 loc) · 2.28 KB
/
Copy pathFiveNumber.java
File metadata and controls
104 lines (70 loc) · 2.28 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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import java.util.Scanner;
public class FiveNumber{
public static void main (String[]args){
Scanner input = new Scanner(System.in);
double even = 0;
double evenCounter = 0;
System.out.print ("Enter the number");
double first = input.nextInt();
System.out.print ("Enter the number");
double second = input.nextInt();
System.out.print ("Enter the number");
double third = input.nextInt();
System.out.print ("Enter the number");
double fourth = input.nextInt();
System.out.print ("Enter the number");
double fifth = input.nextInt();
if (first % 2 == 0){
even = even + first;
evenCounter = evenCounter + 1;
}
if (second % 2 == 0){
even = even + second;
evenCounter = evenCounter + 1;
}
if (third % 2 == 0){
even = even + third;
evenCounter = evenCounter + 1;
}
if (fourth % 2 == 0){
even = even + fourth;
evenCounter = evenCounter + 1;
}
if (fifth % 2 == 0){
even = even + fifth;
evenCounter = evenCounter + 1;
}
if (first > second && first > third && first> fourth && first > fifth){
System.out.println (first + " is largest number");
}
if (second >first && second > third && second > fourth && second > fifth){
System.out.println (second +" is the largest number");
}
if (third > first && third > second && third > fourth && third > fifth){
System.out.println (third + " is the largest number");
}
if (fourth > first && fourth > second && fourth > third && fourth > fifth){
System.out.println (fourth +" is the largest number");
}
if (fifth > first && fifth > second && fifth > third && fifth> fourth){
System.out.println (fifth + " is the largest number");
}
if (first < second && first < third && first < fourth && first < fifth){
System.out.println (first +"is the lowest number");
}
if (second < first && second < third && second < fourth && second < fifth){
System.out.println (second +"is the lowest number");
}
if (third < first && third < second && third < fourth && third < fifth){
System.out.println (third +"is the lowest number");
}
if (fourth < first && fourth < second && fourth < third && fourth < fifth){
System.out.println (fourth +"is the lowest number");
}
if (fifth < first && fifth < second && fifth < third && fifth < fourth){
System.out.println (fifth +"is the lowest number");
}
double average = even /evenCounter;
System.out.printf ("the average of even %.1f", average );
}
}