Discuss the below:
Q1: int numValue = 10;
int answer = 0;
switch(numValue)
{
case 5: answer += 5;
case 10: answer += 10;
case 15: answer += 15;
break;
case 20: answer += 20;
case 25: answer += 25;
default: answer = 0;
break;
}
System.out.println("Answer: " + answer);
• What is the value of answer if the value of numValue is 10?
• What is the value of answer if the value of numValue is 20?
• What is the value of answer if the value of numValue is 5?
• What is the value of answer if the value of numValue is 17?
• Is the break statement in the default case needed? Explain?
Q2: -Design the logic and write the rest of the program using a nested statement. They are using JOptionPane.showInputDialog.
Productivity Score Bonus
<= 30 $25
31-79 $50
80-199 $100
>=200 $200
// EmployeeBonus.java - This program calculates an employee's productivity bonus.
import javax.swing.*;
public class EmployeeBonus
{
public static void main(String args[])
{
// Declare and initialize variables here.
String employeeName;
double numTransactions;
String transactString;
double numShifts;
String shiftString;
double dollarValue;
String dollarString;
double score;
double bonus;
final double BONUS_1 = 25.00;
final double BONUS_2 = 50.00;
final double BONUS_3 = 100.00;
final double BONUS_4 = 200.00;
// This is the work done in the housekeeping() method
employeeName = JOptionPane.showInputDialog("Enter employee's name: ");
shiftString = JOptionPane.showInputDialog("Enter number of shifts: ");
transactString = JOptionPane.showInputDialog("Enter number of transactions: ");
dollarString = JOptionPane.showInputDialog("Enter transactions dollar value: ");
numShifts = Double.parseDouble(shiftString);
numTransactions = Double.parseDouble(transactString);
dollarValue = Double.parseDouble(dollarString);
// This is the work done in the detailLoop() method
// Write your code here (Design the logic and write the rest of the program
//using a nested if statement.
// This is the work done in the endOfJob() method
// Output.
System.out.println("Employee Name: " + employeeName);
System.out.println("Employee Bonus: tiny_mce_markerquot; + bonus);
System.exit(0);
}
}