KaiquanMah commited on
Commit
4cf146f
·
verified ·
1 Parent(s): b3aac10

public static void

Browse files
Week 2: Methods, strings and lists/2B. Hey and bye! ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Write two methods: printHey() and printBye()
2
+
3
+ The methods print either the string "Hey!" or the string "Bye!" according to their name.
4
+
5
+ See an example below:
6
+
7
+ public static void main(String[] args) {
8
+ printHey();
9
+ printBye();
10
+ }
11
+ Program outputs:
12
+
13
+ Hey!
14
+ Bye!
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+ import java.util.Random;
25
+
26
+ public class Test{
27
+ public static void main(String[] args){
28
+ final Random r = new Random();
29
+
30
+
31
+ System.out.println("Testing printHey:");
32
+ printHey();
33
+
34
+ System.out.println("");
35
+
36
+ System.out.println("Testing printBye:");
37
+ printBye();
38
+ }
39
+
40
+
41
+
42
+
43
+
44
+ public static void printHey(){
45
+ System.out.println("Hey!");
46
+ }
47
+
48
+ public static void printBye(){
49
+ System.out.println("Bye!");
50
+ }
51
+
52
+
53
+ }
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+ Testing printHey:
66
+ Hey!
67
+
68
+ Testing printBye:
69
+ Bye!
70
+