CISC 1115
Introduction to Programming Using Java
Lab #6
Logical Operators

How to Develop and Submit your Labs

Lab 6.1 — Vaccination — Take 2 (Vaccination) (Approval)

Modify Program 6.1 to use the && operator instead of the || operator

Sample Test Run #1

Enter patient's age: 2
***** Do NOT ADMINISTER VACCINE *******

Sample Test Run #2

Here is a sample execution of the program.
User input is in bold. Your program should replicate the prompts and output:

Enter patient's age: 3
Go ahead and stick it to 'em

Lab 6.2 — Vaccination — Take 3 (Vaccination)

Modify Program 6.1 (or Lab 6.1) so that the gender of the patient (M/F) is entered, and taken into account, as well. The vaccine should NOT be administered to those patients who match one of the categories in the following table ( a '-' means that no distinction is made for that column):

Age Gender
Under 3 -
20-45 F
Over 65 -

Sample Test Run #1

Enter patient's age: 2
Enter patient's gender: M
***** Do NOT ADMINISTER VACCINE *******

Sample Test Run #2

Here is a sample execution of the program.
User input is in bold. Your program should replicate the prompts and output:

Enter patient's age: 64
Enter patient's gender: F
Go ahead and stick it to 'em

Lab 6.3 — Divisibility Again (Divisibility)

Write a program containing a method boolean divisibleBy17(int n) that returns true if n is divisible by 17 and falseotherwise. Your main should prompt the user for an integer, pass it to the method and print the returned boolean value. (This is a variation of Program 3.1).

Sample Test Run #1

Enter number for which to check divisibility by 17: 17
17 is divisible by 17

Sample Test Run #2

Enter number for which to check divisibility by 17: 15
15 is not divisible by 17

Lab 6.4 — Divisibility Again — Take 2 (Divisibility)

Rewrite Lab 6.4 so that the method is now bool isDivisible(int n, int m). isDivisible returns true if n is divisible by m. Again your main should read in the two numbers, pass them to the method and print the result.

Sample Test Run #1

Enter number to be checked: 10
Enter number to be divided by: 5
10 is divisible by 5

Sample Test Run #2

Enter number to be checked: 3
Enter number to be divided by: 2
3 is not divisible by 2

Lab 6.5 — Evenness (Evenness) (Approval)

Write a program that contains two methods: Your main should prompt for the number, pass it (to isEven, and print the result.

Sample Test Run #1

Enter number to be checked: 12
12 is even

Sample Test Run #2

Lab 6.6 — Fun with Numbers (InfoOf3) (Approval)

Write a program that reads three numbers from the file numbers.text, and then prints out some information about the relationships between the numbers-- whether they are all equal, in ascending order, in descending order, and so on. To determine these relationships, write the following boolean-valued functions: Try to "talk boolean"

Sample Test Run

first number? 1
second number? 2
third number? 3
allAreEqual: false
twoAreEqual: false
noneAreEqual: true
areAscending: true
areDescending: false
strictlyAscending: true
strictlyDescending: false