-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethods.java
More file actions
37 lines (29 loc) · 923 Bytes
/
Methods.java
File metadata and controls
37 lines (29 loc) · 923 Bytes
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
public class Methods {
public static void main(String[] args) {
// Methods
int number = 3;
String firstName = "Spongebob";
String lastName = "Squarepants";
int age = 18;
System.out.println(square(number));
System.out.println(cube(number));
System.out.println(getFullName(firstName, lastName));
if(checkAge(age)) {
System.out.println("You may sign up!");
} else {
System.out.println("You may not sign up!");
}
}
static double square(int number) {
return number * number;
}
static double cube(int number) {
return number * number * number;
}
static String getFullName(String firstName, String lastName) {
return firstName + " " + lastName;
}
static boolean checkAge(int age) {
return age >=18 ? true : false;
}
}