-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayProcess.java
More file actions
80 lines (67 loc) · 1.62 KB
/
Copy pathArrayProcess.java
File metadata and controls
80 lines (67 loc) · 1.62 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
import java.util.Scanner;
public class ArrayProcess
{
public static void main(String[] args)
{
int[] fiveThings = {12, 33, 1, 6, 144};
int fiveTotal = 0;
double fiveAverage;
double[] threeThings;
double threeTotal = 0;
double threeAverage;
threeThings = new double[5];
char[] sevenThings = {'a', 'e', 'o', 'u', 'i', 'y', 'q'};
String[] twoThings;
twoThings = new String[2];
Scanner input = new Scanner(System.in);
System.out.println("Input five numbers: ");
for(int i = 0; i < 5; i++)
{
threeThings[i] = input.nextDouble();
input.nextLine();
}
System.out.println("Input two words: ");
for(int i = 0; i < 2; i++)
{
twoThings[i] = input.nextLine();
}
for(int i = 0; i < 5; i++)
{
fiveTotal += fiveThings[i];
}
fiveAverage = fiveTotal / 5;
System.out.println("Average of 5 integers: ");
System.out.println(fiveAverage);
for(int i = 0; i < 3; i++)
{
threeTotal += threeThings[i];
}
threeAverage = threeTotal / 3;
System.out.println("Average of 3 numbers: ");
System.out.println(threeAverage);
System.out.println("Highest letter: ");
System.out.println(findHighest(sevenThings));
System.out.println("Lowest letter: ");
System.out.println(findLowest(sevenThings));
}
public static char findHighest(char[] arr)
{
char highest = arr[0];
for (int i = 1; i < arr.length; i++)
{
if (arr[i] > highest)
highest = arr[i];
}
return highest;
}
public static char findLowest(char[] arr)
{
char lowest = arr[0];
for (int i = 1; i < arr.length; i++)
{
if (arr[i] < lowest)
lowest = arr[i];
}
return lowest;
}
}