Design the logic and write the rest of the program using a


First Problem

I need help answering the following questions.  I tried to do this in Java but I couldn't get it to execute.

intnumValue = 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?

Second Problem -

need assistance with the area highlighted in yellow.  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.

 

importjavax.swing.*;

publicclassEmployeeBonus
{
publicstaticvoid main(String args[])
   {
// Declare and initialize variables here.
      String employeeName;
doublenumTransactions;
      String transactString;
doublenumShifts;
      String shiftString;
doubledollarValue;
      String dollarString;
double score;
double bonus;
finaldouble BONUS_1 = 25.00;
finaldouble BONUS_2 = 50.00;
finaldouble BONUS_3 = 100.00;
finaldouble 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: $" + bonus);

System.exit(0);
   }
}

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Design the logic and write the rest of the program using a
Reference No:- TGS01249627

Now Priced at $20 (50% Discount)

Recommended (95%)

Rated (4.7/5)