- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionInjava.java
More file actions
Latest commit
88 lines (69 loc) · 2.16 KB
/
Copy pathfunctionInjava.java
File metadata and controls
88 lines (69 loc) · 2.16 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
packagecom.petehouston.tutorial.java;
importjava.util.Arrays;
importjava.util.Scanner;
importjava.lang.Math;
importjava.lang.String;
importjava.util.Random;
publicclassHelloWorld {
publicstaticvoidmain(String[] args) {
Randomrand = newRandom();
int[][] nums = newint[3][3];
for (inti=0; i< nums.length; i++){
for (intj=0; j<nums[i].length; j++) {
intrandNumber = rand.nextInt(50);
intmathRand = 10 +(int) (Math.random()*40);
nums[i][j] = mathRand;
};
}
for (intj=0; j<nums.length; j++){
for (inti=0; i<nums[j].length; i++){
System.out.printf("%d ",nums[j][i]);
}
System.out.println();
}
int[][] matrix = {
{1,2,3},
{7,9,0}
};
System.out.println(Arrays.toString(matrix[0]));
String[][] strings = newString[2][3];
strings[0][1] = "Hello";
System.out.println(strings[0][1]);
hello();
welcome();
inta = 7, b = 8;
intc = sum(a,b);
System.out.println(c);
multip("Meiirzhan",1,2,5,7);
Scannerscan = newScanner(System.in);
System.out.print("\nEnter hour = ");
inth = scan.nextInt();
Stringres = dateTime(h);
System.out.println(res);
}
staticvoidhello(){
System.out.println("Hello Java");
}
staticvoidwelcome(){
System.out.println("Welcome to Java 17.0.1");
}
staticintsum(intx, inty){
intz = x + y;
returnz;
// System.out.printf("Sum %d + %d = %d",x,y,z);
}
staticvoidmultip(Strings, int ...j){
intresult = 1;
for(inti: j){
result *= i;
}
System.out.printf("\n%s , result = %d",s,result);
}
staticStringdateTime(inthour){
if (hour > 24 || hour<0) return"Invalid data";
elseif (hour > 24 || hour < 6) return"Good night";
elseif (hour >= 15) return"Good evening";
elseif (hour >= 11) return"Good afternoon";
elsereturn"Good morning";
}
}