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

This is my first program. Not sure if I even know what I\'m doing. I think I was

ID: 3638795 • Letter: T

Question

This is my first program. Not sure if I even know what I'm doing. I think I was able to fix all the other errors, all that is left when I build the program are:
Variable o might not have been initialized
Variable f might not have been initialized
Variable s might not have been initialized

How do I fix this? Can't find anything in my book or notes..



import javax.swing.JOptionPane;

public class Project1
{
public static void main(String[] args)
{
String input, output;
double o, f, s, employeeType, hourlyRate, hoursWorked, widgetsProduced, totalSales, totalPay, federalTax, kentuckyTax, netPay;

input = JOptionPane.showInputDialog( null, "Specify your job type: o - office clerical f - factory worker s - salesperson" );
employeeType = Double.parseDouble( input );

if ( employeeType == o )
input = JOptionPane.showInputDialog( null, "Enter your hourly rate:" );
hourlyRate = Double.parseDouble( input );

input = JOptionPane.showInputDialog( null, "Enter your total hours worked for the week:" );
hoursWorked = Double.parseDouble( input );

if ( hoursWorked > 40 )
totalPay = 40 * hourlyRate + (hoursWorked - 40 ) * hourlyRate * 1.5;
else
totalPay = hoursWorked * hourlyRate;

if ( employeeType == f )
input = JOptionPane.showInputDialog( null, "Enter the amount of widgets produced for the week:" );
widgetsProduced = Double.parseDouble( input );

totalPay = .35 * widgetsProduced + 300;

if ( employeeType == s )
input = JOptionPane.showInputDialog( null, "Enter your total sales for the week:" );
totalSales = Double.parseDouble( input );

totalPay = .05 * totalSales + 500;

if ( employeeType != o || employeeType != f || employeeType != s )
JOptionPane.showMessageDialog( null, "You entered an invalid job type. Sorry!" );

federalTax = .22 * totalPay;
kentuckyTax = .055 * totalPay;
netPay = totalPay - federalTax - kentuckyTax;

output = String.format( "Totaly Pay %1$7.2f:/n Federal Tax W/H %1$7.2f:/n Kentucky State Tax W/H %1$7.2f:/n Net Pay %1$7.2f:/n", totalPay, federalTax, kentuckyTax, netPay );
JOptionPane.showMessageDialog( null, output );
}
}

Explanation / Answer

//intialize as follows.

double o=0.0, f=0.0, s=0.0

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