-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomDay.java
More file actions
84 lines (70 loc) · 2 KB
/
RandomDay.java
File metadata and controls
84 lines (70 loc) · 2 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
public class RandomDay {
public static void main(String[] args)
{
Day today = Day.MONDAY;
System.out.println(today.name());
System.out.println(today.ordinal());
switch(today){
case SATURDAY:
case SUNDAY:
System.out.println("It is Weekend!");
break;
default:
System.out.println("It is Week Days!");
}
int[] myArray = new int[100];
for(int i = 0; i < myArray.length; i++)
{
myArray[i] = (int) (1000 * Math.random()); // 0 - 999
}
int largest = Integer.MIN_VALUE;
int second_large = Integer.MIN_VALUE;
for(int i = 0; i < myArray.length; i++)
{
if (myArray[i] > largest)
{
second_large = largest;
largest = myArray[i];
}
else if(myArray[i] > second_large)
{
second_large = myArray[i];
}
}
System.out.println(largest);
System.out.println(second_large);
int[][] arr = {
{1, 2, 3},
{4, 5},
{6}
};
int sum =0;
for(int i = 0; i < arr.length; i++)
{
for(int j = 0; j < arr[i].length; j++)
{
sum += arr[i][j];
}
}
for(int[] i : arr)
{
for(int j : i)
{
sum += j;
}
}
System.out.println(sum);
System.out.println(Colors.BLUE);
Colors myColor = Colors.RED;
System.out.println(myColor.name());
String a, b, c, d, e;
a = "Computer Science";
b = new String("1331");
c = a.replace('C', 'd');
d = a.substring(0,3);
e = a.substring(a.length()-7, a.length()-4);
System.out.println(a + " - " + b);
System.out.println(c + " - " + b);
System.out.println(d + e + " - " + b);
}
}