forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee.java
More file actions
57 lines (51 loc) · 1.7 KB
/
Employee.java
File metadata and controls
57 lines (51 loc) · 1.7 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
import java.util.Scanner;
import java.util.Random;
public class Employee
{
public static void main(String[] args)
{
System.out.println("Employee");
int birthYear= 1995;
boolean isUnionMember= true;
int employeeNumber;
Scanner scanner=new Scanner(System.in);
printHeader();
System.out.println("Please enter your 5 digit employee number: ");
employeeNumber=scanner.nextInt();
printFullName("Luke ","Allen ", "Martin, ");
printUnionStatus(true);
printAge(1995);
printEvenOrOdd(101545);
printGenerateSecretPassword(2);
}
private static void printHeader()
{
System.out.println("Welcome to the WallabyTech Employee Application");
System.out.println("===============================================");
}
private static void printFullName (String first, String middle, String last)
{
System.out.println(last+first+middle);
}
private static void printUnionStatus(boolean union)
{
System.out.println("Your union status is: "+union);
}
private static void printAge(int birthYear)
{
int currentYear= 2018;
System.out.println("Your age is: "+(currentYear-birthYear));
}
private static void printEvenOrOdd(int eo)
{
System.out.println("Employee number is even/odd (1=odd, 0=even);");
System.out.println(eo%2);
}
private static void printGenerateSecretPassword(int password)
{
Random random=new Random();
int employeeNumber=101545;
int randomNumber=random.nextInt(10)+1;
System.out.println("Employee's random secret pw is: "+(employeeNumber*randomNumber)*5);
}
}