Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. For the following problem statement, would you include an if/else statement o

ID: 3869433 • Letter: 2

Question

2. For the following problem statement, would you include an if/else statement or a switch statemen? Explain your answer. Be sure to address both types of statements in your answer.(You do not need to write the code)

a. Write a program that determines the bonus that should be paid to employees. Bonuses are determined based on the year;s production. The bonus is $25 for 1000 units or fewer. The bonus is $50 for 1001 to 3000 units. The bonus is $100 for 30001 units or more?

b. Write a statment to declare a named constant called NUM that has an integer value of zero.

c. Given an array declared as: int[] counter=new int[10]; write a for loop to intilaize each element of the counter array to zero.

d. Given the following class header, what method do you expext to see in this class as a result of implements ActionListener and why?public class NameCompare extends JFrame implements ActionListenter

Explanation / Answer

In the program, bonus is dentermined from the number of units. For 1001 to 3000 units, bonus is 50$, for 30001 units or more, bonus is 100$. So, bonus depends on the rante of number of units rather than the number of units itself. In this case if else must be used.

The statement to declare a constant is final int NUM = 0

int[] counter = new int[10];
for(int i=0;i<counter.length;i++){
   counter[i] = 0;
}

Since ActionListener is an interface, public void actionPerformed(ActionEvent ae) must be implemented in the class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote