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
68 lines (57 loc) · 1.92 KB
/
Employee.java
File metadata and controls
68 lines (57 loc) · 1.92 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
//Exercise 4-H.
import java.util.Scanner;
import java.util.Random;
public class Employee
{
public static void main(String[] args)
{
int birthYear = 1995;
boolean isUnionMember = false;
String firstName = "Robin";
String middleName = "Ann";
String lastName = "Daniel";
int employeeNumber;
printHeader();
Scanner in = new Scanner(System.in);
System.out.println("Please enter your 5 digit employee number: ");
employeeNumber = in.nextInt();
printFullName(lastName, firstName, middleName);
printUnionStatus(isUnionMember);
printAge(birthYear);
printEvenOrOdd(employeeNumber);
printGenerateSecretPassword(employeeNumber);
}
private static void printHeader()
{
String header = "Welcome to the WallabyTech Employee Application\n";
header += "-----------------------------------------------\n";
System.out.print(header);
}
private static void printFullName(String ln, String fn, String mn)
{
System.out.println(ln + ", " + fn + " " + mn);
}
private static void printUnionStatus(boolean s)
{
System.out.println("Your union status is: " + s);
}
private static void printAge(int a)
{
final int CURRENT_YEAR = 2018;
int age = CURRENT_YEAR - a;
System.out.println("Your age is: " + age);
}
private static void printEvenOrOdd(int n)
{
int typeOfNumber = (n % 2);
System.out.println("Employee Number is even (0) or odd (1): " + typeOfNumber);
}
private static void printGenerateSecretPassword(int n)
{
Random random = new Random();
int number = random.nextInt(10) + 1;
int password = ((n + number) * 5);
// System.out.println(number); //Did this to check the computation.
System.out.println("Employee's random secret ps is: " + password);
}
}