Expand|Select|Wrap|Line Numbers
- //Title: Programming Assignment 1
- //Version:
- //Copyright: Copyright (c) 1999
- //Author: Andrew
- //Company:
- //Description: Computes employee's weekly gross and net pay.
- package prog1;
- import javax.swing.JOptionPane;
- public class GrossNetPay {
- public static void main (String args[]) {
- //declare variables
- //The numbers we obtain from the user
- int status;
- //The number of hours worked
- double hours;
- //Employee's rate of pay
- double rate;
- //Stores the result of the input dialog box
- String inputString;
- //Gross pay of employee
- double grossPay;
- //Employee tax deduction
- double taxes;
- //Employee pay after deductions
- double net;
- //Full time employee's base pay for 40 hours
- double basePay;
- //Full time employee's pay for overtime hours
- double overtimePay;
- //get number of hours worked
- inputString = JOptionPane.showInputDialog ("Number of Hours Worked: ");
- hours = Double.parseDouble(inputString);
- System.out.println ("Hours worked: " + hours);
- //get employee rate of pay
- inputString = JOptionPane.showInputDialog ("Employee's Rate of Pay: $");
- rate = Double.parseDouble(inputString);
- System.out.println ("Rate of Pay: $" + rate);
- //determine employee's status
- inputString = JOptionPane.showInputDialog ("Employee Status is: ( 1-Full Time, 2-Part Time )");
- status = Integer.parseInt(inputString);
- {
- if (status == 1) { //compute gross and net pay for full time employee
- System.out.println ("Employment status is full-time.");
- }
- //initialize gross pay
- grossPay = 0;
- if (hours <= 40)
- { grossPay = hours * rate;
- taxes = grossPay * .254;
- net = grossPay-taxes-100;
- System.out.println ("The weekly gross pay is $" + grossPay);
- System.out.println ("The weekly net pay is $" + net);
- }
- //initialize basePay
- basePay = 0;
- else
- {
- basePay = 40 * rate;
- overtimePay = (hours - 40) * 1.5 * rate;
- grossPay = basePay + overtimePay;
- taxes = grossPay * .254;
- net = grossPay-taxes-100;
- System.out.println (" The weekly gross pay is $" + grossPay);
- System.out.println (" The weekly net pay is $" + net);
- end if}
- if (status == 2) //compute gross and net pay for part time employee
- System.out.println ("Employment status is part-time.");
- //initialize gross pay
- grossPay = 0;
- grossPay = hours * rate;
- taxes = grossPay * .254;
- net = grossPay-taxes-100;
- System.out.println ("The weekly gross pay is $" + grossPay);
- System.out.println ("The weekly net pay is $" + net);
- }}}
My problem is it keeps giving me a "else with if" error on line 68 ( the line that actually has the "else" on it)
not sure why this is happening and need some help before the assignment deadline..
if you need any other info to answer this question please write back and any help in completing this would be greatly appreciated.