Java Programming Lab 20522 – 20559

20522
Write an expression that evaluates to true if and only if the value of the integer variable x is equal to zero.
So if the value of x were 3 the expression would be false. Only if the value of x were 0 would the expression be true.
SOLUTION
x==0
————————————————————————————————————
20533
Write an expression that evaluates to true if and only if the variables profits and losses are exactly equal .
SOLUTION
profits==losses
————————————————————————————————————
20554
Given the char variable c , write an expression that is true if and only if the value of c is not the space character .
SOLUTION
c!=’ ‘
————————————————————————————————————
20555
Write an expression that evaluates to true if the value of index is greater than the value of lastIndex .
SOLUTION
index>lastIndex
————————————————————————————————————
20556
Working overtime is defined as having worked more than 40 hours during the week. Given the variable hoursWorked , write an expression that evaluates to true if the employee worked overtime.
SOLUTION
hoursWorked>40
————————————————————————————————————
20557
Write an expression that evaluates to true if the value x is greater than or equal to y .
SOLUTION
x>=y




————————————————————————————————————
20558
Given the variables numberOfMen and numberOfWomen , write an expression that evaluates to true if the number of men is greater than or equal to the number of women.
SOLUTION
numberOfMen>=numberOfWomen
————————————————————————————————————
20559
Given a double variable called average , write an expression that is true if and only if the variable ‘s value is less than 60.0 .
SOLUTION
average<60

Write the definition of a class Counter containing:

 

%d bloggers like this: