Advanced Boolean Logic Practice
Credit: Structured Programming 2
You are asked to analyze an employee salary program by your boss because he thinks it has some flaws. An employee can receive a bonus if he has at least $101 in sales or 21 customers. Look at the IF statements below and write down what is prints for a sample employee.
Applicable to all code in this assignment
int hours = 30;
float wage = 20;
int sales = 200;
int numCustomers = 8;
int department = 3;
Q1.
if (hours < 35 && department==2) {
println(“Part time employee in Hardware”);
} else {
println(“Full time employee”);
}
Q1: What gets printed by the above code?:
Q2.
if (hours < 35 || department==2) {
println(“Part time employee in Hardware”);
} else {
println(“Full time employee”);
}
Q2: What gets printed by the above code?:
Q3.
if (wage < 20 && hours > 25 && sales > 300) {
println(“You get a bonus..”);
} else {
println(“Regular wage”);
}
Q3 Prints:
Q4.
if ( !(sales > 100) ) {
println(“You get a bonus!”);
} else {
println(“No bonus this week.”);
}
Q4 Prints:
Q5.
if (hours == 30 || wage ==40) {
println(“Part time employee”);
} else{
println(“Full time employee”);
}
Q5 Prints:
Q6.
if (sales < 25 || numCustomers < 10) {
println(“You’re fired!”);
} else if (sales < 100) {
println(“No bonus this week.”);
} else {
println(“You get a bonus!”);
}
Q6 Prints:
Q7. if (numCustomers < 21 && numCustomers >5) {
println(“Decent week but no bonus this week.”);
} else if (numCustomers > 20) {
println(“Good week. You get a bonus”);
} else {
println(“Your fired”);
}
Q7. Prints:
Q8. Write an if statement that will prints out “Sales person of the year” if both sales is greater than 300 and numCustomers is greater than 20.
Q9. Write an if statement that will prints out “You are NOT in the hardware department” if your department does NOT EQUAL 2.
Q10. Write an if statement that will prints out “You should look for a new job ” if your hour are less than 20 OR your wage is less than 20..