CISC 1115
Introduction to Programming Using Java
Lab #3
Conditionals

How to Develop and Submit your Labs

Lab 3.1 — Out with the Old …

Picosoft Computer Systems, Inc. finally decides to computerize their and hires you as the software developer. In addition, the company requires downsizing, due to the sagging economy; and management has thus decided to institute a mandatory retirement age of 65., and has asked you to write a program to help them identify the employees subject to this new rule.

Write a program that input an employee's last name, first name, and age, and if the employee is 65 or older, displays the employee's name together with the words "must retire" on the screen (nothing should be displayed if the employee is below the retirement age).

Here is a good opportunity to practice your copy/paste (or duplicate source file) skills. Feel free to use your original payroll program's (Lab 1.3/1.4) source as a starting point (it has some of the code you will be using-- the boilerplate of course, some of the declarations, the code to read in the last and first name, possibly the for loop,...)

Sample Test Run #1

Enter last name: Weiss
Enter first name: Gerald
Enter age: 50

Sample Test Run #2

Enter last name: Arnow
Enter first name: David
Enter age: 70
David Arnow must retire

Lab 3.2 — Bonuses!!! Approval

You're on a roll to taking over the world's payroll software market!

Now that the company has reduced it workforce and dramatically cut expenses, BONUSES can be given to the top-level executives (departments 1 and 2)! But given the public's anger at outrageous payouts to executives, management has decided to give EVERYONE a bonus: executives get cash, while the rest of the company get a cute little teddy bear with the company name on its belly.

Write a program that reads in (from the keyboard) an employee's last name, first name, and department number, and displays the employee's name and the bonus they shooed receive: either the string "$$$!!!" or the string "Cute little Teddy Bear"

Sample Test Run #1

Enter last name: Weiss
Enter first name: Gerald
Enter department #: 2
Gerald Weiss gets $$$!!!

Sample Test Run #2

Enter last name: Arnow
Enter first name: David
Enter department #: 1
David Arnow gets $$$!!!

Lab 3.3 — A General Multiples Checker

Modify Program3.1 so that the user is prompted for: Sample Test Run
Enter number whose multiples are to be printed: 5
Enter last number to be checked: 36
5 is divided evenly by 5
10 is divided evenly by 5
15 is divided evenly by 5
20 is divided evenly by 5
25 is divided evenly by 5
30 is divided evenly by 5
35 is divided evenly by 5

Lab 3.4 — PicoSoft Damage Control Approval

That last idea at PicoSoft didn't work out too well … management has a massive public relations disaster on their hands, and thus they decide to revise the bonus structure, as well as give eveyone some additional vacation time.

Write a program that reads in (from the keyboard) the following information about an employee:

An employee's vacation time is based upon the following table:

Years worked Weeks of vacation
0-3 1
4-6 2
7 or more 3

Bonuses are determined by the following table:

Years worked Bonus
0-4 None
5-9 $200
10 or more 5% of annual salary

Your program should read in the information for an employee, calculate the vacation time and bonus amount for the employee, and display the employee's name, number of years worked, number of weeks of vacation and amount of bonus (on a single line). Please note that you are to print the actual amount of the bonus (calculated as 5% of the annual salary), and not simply the words 5% of salary".

This should be done for eight (8) employee (using a for loop).

Sample Test Run

Enter last name: Weiss
Enter first name: Gerald
Enter years worked: 1
Enter salary: 100
Gerald Weiss gets 1 weeks vacation, and a bonus of $0

Enter last name: Arnow
Enter first name: Davis
Enter years worked: 3
Enter salary: 200
Davis Arnow gets 1 weeks vacation, and a bonus of $0

Enter last name: Tenenbaum
Enter first name: Aaron
Enter years worked: 4
Enter salary: 100
Aaron Tenenbaum gets 2 weeks vacation, and a bonus of $0

Enter last name: Thurm
Enter first name: Joe
Enter years worked: 6
Enter salary: 100
Joe Thurm gets 2 weeks vacation, and a bonus of $200

Enter last name: Whitlock
Enter first name: Paula
Enter years worked: 7
Enter salary: 400
Paula Whitlock gets 3 weeks vacation, and a bonus of $200

Enter last name: Jones
Enter first name: Jackie
Enter years worked: 9
Enter salary: 500
Jackie Jones gets 3 weeks vacation, and a bonus of $200

Enter last name: Dreizen
Enter first name: Phil
Enter years worked: 10
Enter salary: 1000
Phil Dreizen gets 3 weeks vacation, and a bonus of $50

Enter last name: Augenstein
Enter first name: Moshe
Enter years worked: 12
Enter salary: 1500
Moshe Augenstein gets 3 weeks vacation, and a bonus of $75

Lab 3.5 — Monkey in the Middle Approval

The median of a set of numbers is that number that falls into the middle when the numbers are in order. Thus the median of the numbers 12 19 4 24 27 84 6 is 19 (4 6 12 19 24 27 84). In particular the median of a set of three numbers if the number that falls in the middle, i.e., neither the minimum nor the maximum.

We presented in class a somewhat intricate method to calculate the maximum of three values, involving nested if/else statements (Program 3.3). Using the same approach (i.e.,nested if/else's enumerating all the possibilities) write a program that prompts for three integers and prints their median.

Sample Test Run

Enter first number: 1
Enter second number: 2
Enter third number: 3
The median is: 2