|
| 1 | +//Exercise 4-H. |
| 2 | + |
| 3 | +import java.util.Scanner; |
| 4 | +import java.util.Random; |
| 5 | + |
| 6 | +public class Employee |
| 7 | +{ |
| 8 | + public static void main(String[] args) |
| 9 | + { |
| 10 | + int birthYear = 1995; |
| 11 | + boolean isUnionMember = false; |
| 12 | + String firstName = "Robin"; |
| 13 | + String middleName = "Ann"; |
| 14 | + String lastName = "Daniel"; |
| 15 | + int employeeNumber; |
| 16 | + |
| 17 | + printHeader(); |
| 18 | + |
| 19 | + Scanner in = new Scanner(System.in); |
| 20 | + System.out.println("Please enter your 5 digit employee number: "); |
| 21 | + employeeNumber = in.nextInt(); |
| 22 | + |
| 23 | + printFullName(lastName, firstName, middleName); |
| 24 | + printUnionStatus(isUnionMember); |
| 25 | + printAge(birthYear); |
| 26 | + printEvenOrOdd(employeeNumber); |
| 27 | + printGenerateSecretPassword(employeeNumber); |
| 28 | + } |
| 29 | + |
| 30 | + private static void printHeader() |
| 31 | + { |
| 32 | + String header = "Welcome to the WallabyTech Employee Application\n"; |
| 33 | + header += "-----------------------------------------------\n"; |
| 34 | + System.out.print(header); |
| 35 | + } |
| 36 | + |
| 37 | + private static void printFullName(String ln, String fn, String mn) |
| 38 | + { |
| 39 | + System.out.println(ln + ", " + fn + " " + mn); |
| 40 | + } |
| 41 | + |
| 42 | + private static void printUnionStatus(boolean s) |
| 43 | + { |
| 44 | + System.out.println("Your union status is: " + s); |
| 45 | + } |
| 46 | + |
| 47 | + private static void printAge(int a) |
| 48 | + { |
| 49 | + final int CURRENT_YEAR = 2018; |
| 50 | + int age = CURRENT_YEAR - a; |
| 51 | + System.out.println("Your age is: " + age); |
| 52 | + } |
| 53 | + |
| 54 | + private static void printEvenOrOdd(int n) |
| 55 | + { |
| 56 | + int typeOfNumber = (n % 2); |
| 57 | + System.out.println("Employee Number is even (0) or odd (1): " + typeOfNumber); |
| 58 | + } |
| 59 | + |
| 60 | + private static void printGenerateSecretPassword(int n) |
| 61 | + { |
| 62 | + Random random = new Random(); |
| 63 | + int number = random.nextInt(10) + 1; |
| 64 | + int password = ((n + number) * 5); |
| 65 | +// System.out.println(number); //Did this to check the computation. |
| 66 | + System.out.println("Employee's random secret ps is: " + password); |
| 67 | + } |
| 68 | +} |
0 commit comments