Published using Google Docs
Boolean Logic Practice #1
Updated automatically every 5 minutes

Boolean Logic Practice #1

Credit: Structured Programming 2

You are asked to analyze an employee salary program by your boss because he thinks it has some flaws.  Look at the IF statements below and write down what it prints for a sample employee.

Applicable to all code in this assignment

int hours = 30;

float wage = 20;

int sales = 200;

int numCustomers = 5;

int department = 3;

boolean isManager = false;

char experienceLevel = ‘c’;

Notes:

Q1.

if (hours < 35) {

        println(“Part time”);

} else {

        println(“Full time”);

}

What gets printed by the above code?:    

Q2.

if (wage < 20) {

        println(“Trainee wage.”);

} else {

        println(“Regular wage”);

}

println(“This week’s pay is: ” + (hours * wage));

What gets printed by the above code?:

Q3.

if (sales > 100) {

        println(“You get a bonus!”);

} else {

        println(“No bonus this week.”);

}

What gets printed by the above code?:

Q4.

if (hours == 30) {

        println(“Part time employee”);

}

println(“Full time employee”);

What gets printed by the above code?

Q5

if (sales < 25) {

        println(“You’re fired!”);

} else if (sales < 100) {

        println(“No bonus this week.”);

} else {

        println(“You get a bonus!”);

}

What gets printed by the above code?

Q6

if (numCustomers < 21) {

        println(“No bonus this week.”);

} else if (numCustomers < 10) {

println(“More training needed”);        

} else {

        println(“You get a bonus”);

}

What gets printed by the above code?

Q7

if (isManager) {

        println(“Bonus this week”);

}else {

        println(“You get a bonus!”);

}

What gets printed by the above code?

Q8

if (experienceLevel == ‘c’){

println(“You are moving up one level”);

experienceLevel = ‘d’;

wage = 25;

} else {

        println(“Sorry, your level moves up next month”);

}

What gets printed by the above code?

What variables are changed?