Tutorial 7
Tutorial 7
Tutorial 7
Activity 1
Implement a class Employee. An employee has a name and a salary. Provide a constructor with
two parameters:
and methods:
These methods return the name and salary, and raise the employee’s salary by a certain percentage.
Sample usage:
Deliverable
Employee.java
EmployeeTester.java
Activity 2
Write a program that reads an integer and output its binary form. This exercise was already
included in a previous tutorial. However, this time you’re required to implement a recursive
method to convert a decimal integer into a binary string.
Deliverable
RecursiveDec2Bin.java
Activity 3
Write and run a recursive method to reverse a string.
Expected result
Deliverable
RecursiveStringReverse.java
Activity 4
Write a program that reads a number between 1,000 and 999,999 from the user and prints it with
a comma separating the thousands.
(*) Use what you’ve learned about exception handling to make sure the user enters a valid integer
and that integer is between the required range.
Expected result
Deliverable
ThousandSeparatingComma.java
Activity 5
Ask user to enter a password. Measure its strength with the following rules:
Length:
o From 8 to 12, 1 point.
o > 12, 2 points.
Contains at least one uppercase letter: 1 point
Contains at least one lowercase letter: 1 point
Contains at least one digit: 1 point
Contains non-alphanumeric characters (symbols): 1 point
Then rate the strength:
1-2 points: weak
3-4 points: medium
5-6 points: strong
Expected result
Case 1:
Enter a new password: 123456
Strength: 1 (weak)
Case 2:
Enter a new password: andrew1974
Strength: 3 (medium)
Case 3:
Enter a new password: peterX124%_beTTy
Strength: 6 (strong)
Deliverable
PasswordStrength.java