Can someone explain to me what am I doing wrong in the code The input is Employe
ID: 3684405 • Letter: C
Question
Can someone explain to me what am I doing wrong in the code The input is Employee's name: Kim Smith, number of shifts: 25, Number of transactions: 75, Transaction dollar value: 40000.00, The output needs to be Employee's name: Kim Smith employee bonus: $50.0 /// 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 = Kim Smith; double numTransactions = 25; String transactString; double numShifts = 75; String shiftString; double dollarValue = 40000; String dollarString; double score; double bonus = 0; final double BONUS_1 = 50.00; final double BONUS_2 = 75.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 int numofTran = Integer.parseInt(shiftString); if(numofTran <=30){ bonus = BONUS_1; } else if(numofTran > 30 && numofTran < 70){ bonus = BONUS_2; } else if(numofTran >= 70 && numofTran < 200){ bonus = BONUS_3; } else if(numofTran >= 200){ bonus = BONUS_4; } // 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); } }
Explanation / Answer
import javax.swing.*;
public class EmployeeBonus{
public static void main(String args[]) {
// Declare and initialize variables here.
String employeeName = "Kim Smith";
int numShifts = 25;
String shiftString;
int numTransactions = 75;
String transactString;
double dollarValue = 40000.00;
String dollarString;
double score;
double bonus = 0.00;
final double BONUS_1 = 50.00;
final double BONUS_2 = 75.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 = Integer.parseInt(shiftString);
numTransactions = Integer.parseInt(transactString);
dollarValue = Double.parseDouble(dollarString);
// This is the work done in the detailLoop() method
// Write your code here
int numofTran = Integer.parseInt(shiftString);
if(numofTran <=30){ bonus = BONUS_1; }
else if(numofTran > 30 && numofTran < 70){ bonus = BONUS_2; }
else if(numofTran >= 70 && numofTran < 200){ bonus = BONUS_3; }
else if(numofTran >= 200){ bonus = BONUS_4; }
// 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);
}
}