-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWord.java
More file actions
106 lines (53 loc) · 1.47 KB
/
Word.java
File metadata and controls
106 lines (53 loc) · 1.47 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
104
105
106
import java.util.Arrays;
public class Word{
public static void main(String [] args){
String word = "hello world";
System.out.println(sentence(word));
int number = 120;
response(number);
int [] number1 = {4,2,8,1,12};
System.out.println(Arrays.toString(largestNumber( number1)));
int [] number2 = {4,2,8,1,12};
System.out.println(Arrays.toString( sortedNumber( number2)));
}
public static String sentence(String word){
return word;
}
public static void response(int number){
for(int count = 1; count <= number; count++){
if(count % 4 == 0 && count % 6 == 0){
System.out.println("Hello world");
}
else if(count % 4 == 0){
System.out.println("Hello");
continue;
}
else if (count % 6 == 0){
System.out.println("World");
continue;
}
System.out.println(count);
}
}
public static int[] largestNumber(int [] number){
int largest = 0;
for(int count = 0; count < number.length; count++){
if(number[count] > largest){
largest = number[count];
}
}
return new int[] {largest};
}
public static int[] sortedNumber(int [] number){
for(int count = 0; count < number.length; count++){
for(int counter = 0; counter < number.length - 1 - count; counter++){
if(number[counter] > number[counter + 1]){
int temp = number[count];
number[count] = number[counter + 1];
number[counter + 1] = temp;
}
}
}
return number;
}
}