|
| 1 | +import java.util.Random; |
| 2 | +import java.util.Scanner; |
| 3 | + |
| 4 | +public class Employee |
| 5 | +{ |
| 6 | + public static void main(String[] args) |
| 7 | + { |
| 8 | + Scanner scanner = new Scanner(System.in); |
| 9 | + int birthYear = 1998; |
| 10 | + boolean isUnionMember = true; |
| 11 | + String firstName = "Sigh"; |
| 12 | + String middleName = "Lent"; |
| 13 | + String lastName = "Tee"; |
| 14 | + int employeeNumber; |
| 15 | + |
| 16 | + printHeader(); |
| 17 | + |
| 18 | + System.out.println("Please enter your 5 digit employee number: "); |
| 19 | + employeeNumber = scanner.nextInt(); |
| 20 | + |
| 21 | + printFullName(firstName, middleName, lastName); |
| 22 | + |
| 23 | + printUnionStatus(isUnionMember); |
| 24 | + |
| 25 | + printAge(birthYear); |
| 26 | + |
| 27 | + printEvenOrOdd(employeeNumber); |
| 28 | + |
| 29 | + printGeneratedSecretPassword(employeeNumber); |
| 30 | + } |
| 31 | + |
| 32 | + public static void printHeader() |
| 33 | + { |
| 34 | + System.out.println("Welcome to the WallabyTech Employee Application"); |
| 35 | + System.out.println("==============================================="); |
| 36 | + } |
| 37 | + |
| 38 | + public static void printFullName(String firstN, String middleN, String lastN) |
| 39 | + { |
| 40 | + System.out.print(lastN + ", "); |
| 41 | + System.out.print(firstN + " "); |
| 42 | + System.out.println(middleN); |
| 43 | + } |
| 44 | + |
| 45 | + public static void printUnionStatus(boolean tOrF) |
| 46 | + { |
| 47 | + System.out.println("Your union status is: " + tOrF); |
| 48 | + } |
| 49 | + |
| 50 | + public static void printAge(int yearBorn) |
| 51 | + { |
| 52 | + int currentYear = 2018; |
| 53 | + int employeeAge = currentYear - yearBorn; |
| 54 | + System.out.println("Your age is: " + employeeAge); |
| 55 | + } |
| 56 | + |
| 57 | + public static void printEvenOrOdd(int evenOdd) |
| 58 | + { |
| 59 | + int evenOddMath = evenOdd % 2; |
| 60 | + System.out.print("Employee number is even/odd (1=odd, 0=even);"); |
| 61 | + System.out.println(evenOddMath); |
| 62 | + } |
| 63 | + |
| 64 | + public static void printGeneratedSecretPassword(int empNumber) |
| 65 | + { |
| 66 | + // pick a random number |
| 67 | + Random random = new Random(); |
| 68 | + int randomNumber = random.nextInt(10) + 1; |
| 69 | + |
| 70 | + int password = (empNumber + randomNumber) * 5; |
| 71 | + |
| 72 | + System.out.println("Employee's random secret pw is: " + password); |
| 73 | + } |
| 74 | +} |
0 commit comments