CS 1401 Homework #5

Date Assigned: Tuesday, February 15, 2005

Due Date: Thursday, February 17, 2005, before the beginning of your lecture section.

Goal: the goal of this assignment is to learn how to deal with Boolean variables and if-then statements in Java.

Assignments:

Let us assume that we have a variable salary of type int, and a variable name of type String.

1. In each subproblem, write Java statements that assign, to a Boolean variable bool, the value "true" or "false" depending on whether the following conditions hold:

(a) 6 < salary

(b) 6 < salary < 10

(c) the variable name contains the string "Gang"

(d) the value of the string name follows "Gang" in alphabetic order

(e) the salary (i.e., the value of the variable salary) is larger than 6, and the name (i.e., the value of the variable name) is different from "Gang"

2. Write a piece of code that does the following: