Thanks.....i got it. Now im having trouble figuring out how to pass a
string like "empName" AND doubles to the print_payroll function. If i declare things like ftax,stax, and ltax as doubles, I dont know how to pull a string like empName in as well.
package acmeCarSales;
import javax.swing.JOptionPane;
public class acmeCarSales
{
public static void main(String[] args){
double ltax,stax,ftax,npay,empname,type;
double commission = 0;
double gpay=0;
String comAnswer = "";
String payType = "";
String empName = "";
String pay = "";
//prompt user for his or her name
String employeeNameString=JOptionPane.showInputDialog(
"Enter your full name:");
empName=employeeNameString;
//Call to pay type method
int ptype=read_pay_type();
//Call to Yes/No commission method
int ctype=read_comm_type();
//prompt for salary for hourly OR salaried employee
if(ptype==1)
pay="Salary";
else
if(ptype==2)
pay="Hourly";
if(ptype==1){
String weeklySalaryString=JOptionPane.showInputDialog(
"Please enter your weekly salary:");
//salaried pay
gpay=Double.parseDouble(weeklySalaryString);
}else{
String hoursWorkedString=JOptionPane.showInputDialog(
"Please enter the hours worked:");
String ratePerHourString=JOptionPane.showInputDialog(
"Please enter your hourly rate:");
double hours=Double.parseDouble(hoursWorkedString);
double rate=Double.parseDouble(ratePerHourString);
}
if(ctype==1)
comAnswer="Yes";
else
if(ctype==2)
comAnswer="No";
//prompt user for the weekly sales
String weeklySalesString=JOptionPane.showInputDialog(
"Enter your sales for the week:");
//Convert weekly sales to a double
double weeklySales=Double.parseDouble(weeklySalesString);
if(ctype==1)
commission=calculate_commission(weeklySales);
gpay = gpay + commission;
ltax = gpay * .01;
stax = gpay * .06;
ftax = gpay * .20;
npay = gpay - (ltax + stax + ftax);
print_payroll(empName);
print_payroll(gpay,ftax,stax,ltax);
}//END MAIN METHOD
//Method to take in salary or hourly pay type
public static int read_pay_type(){
int result=0;
String payRateString=JOptionPane.showInputDialog (
"Enter 1 for salary or 2 for hourly:");
//convert answer to integer
int answer=Integer.parseInt(payRateString);
return result;
}
//Method to read in if commission or not
public static int read_comm_type(){
int result=0;
String commissionStatusString=JOptionPane.showInputDialog(
"Are you on commission? 1 for yes, 2 for no:");
//convert answer to integer
int CommStatus=Integer.parseInt(commissionStatusString);
return result;
}
//Method to calculate commission based on weeklysales
public static double calculate_commission(double weeklySales){
double comm=0;
if(weeklySales < 50000)
comm = weeklySales * .05;
else if(weeklySales >=50000)
comm = weeklySales * .10;
else if(weeklySales < 100000)
comm = weeklySales * .10;
else if(weeklySales >= 100000)
comm = weeklySales * .15;
return comm;
}
//Method to print the payroll information
public static void print_payroll(gpay,ftax,stax,ltax){
String output ="ACME CAR DEALERSHIP";
System.out.println("Gross pay = "+gpay);
System.out.println("Federal tax = "+ftax);
System.out.println("State tax = "+stax);
System.out.println("Local tax = "+ltax);
}
}//End of the Acme Car class