&&
operator instead of the ||
operator
Sample Test Run #1
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:
Age | Gender |
---|---|
Under 3 | - |
20-45 | F |
Over 65 | - |
Sample Test Run #1
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:
boolean divisibleBy17(int n)
that returns true
if n
is divisible by 17 and false
otherwise.
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
Sample Test Run #2
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
Sample Test Run #2
isDivisible
method of Lab 6.4
boolean isEven(int n)
, that returns whether n is even or not
isEven
must be written using isDivisible
main
should prompt for the number, pass it (to isEven
, and
print the result.
Sample Test Run #1
Sample Test Run #2
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:
boolean allAreEqual(int a, int b, int c);
boolean twoAreEqual(int a, int b, int c);
// false
if all three are equal
boolean noneAreEqual(int a, int b, int c);
boolean areAscending(int a, int b, int c);
// true
if a <= b <= c
boolean areDescending(int a, int b, int c);
// true
if a >= b >= c
boolean strictlyAscending(int a, int b, int c);
// true
if a < b < c
boolean strictlyDescending(int a, int b, int c);
// true
if a > b > c
Sample Test Run