-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethod.java
More file actions
94 lines (82 loc) · 2.1 KB
/
Copy pathMethod.java
File metadata and controls
94 lines (82 loc) · 2.1 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
package com.example.method;
public class Method {
public static int age;
public static char gender;
public static int age2;
public static char gender2;
public static void setAge(int x){
age = x;
}
public static void setGender(char x){
gender = x;
}
public static void vote(){
if(age >= 18){
System.out.println("Can vote");
}
else{
System.out.println("Cannot vote");
}
}
public static void shot(){
if(age % 4 == 0){
System.out.println("Need tetanus shot");
}
else{
System.out.println("Do not need tetanus shot");
}
}
public static void toddler(){
if(age < 4 && gender == 'b'){
System.out.println("Toddler boy");
}
if(age < 4 && gender == 'g'){
System.out.println("Toddler girl");
}
else{
System.out.println("Not a toddler");
}
}
public static void discount(){
if(age < 12 || age > 65){
System.out.println("Have discounts");
}
else{
System.out.println("Do not have discounts");
}
}
public static void teenager(){
if(age > 12 && age < 18){
System.out.println("Teenager");
}
else{
System.out.println("Not a teenager");
}
}
public static void setAge2(int x){
age2 = x;
}
public static void setGender2(char x){
gender2 = x;
}
public static void teammates(){
if(Math.abs(age - age2) <= 2 && gender == gender2){
System.out.println("Can be teammates");
}
else{
System.out.println("Cannot be teammates");
}
}
public static void main(String[]args){
setAge(18);
setGender('b');
vote();
shot();
toddler();
discount();
teenager();
setAge2(16);
setGender2('b');
teammates();
}
}