View Single Post
  #9 (permalink)  
Old 05-07-2008, 08:45 PM
Azzia Azzia is offline
Member
 
Join Date: May 2008
Location: Ohio
Posts: 20
Azzia is on a distinguished road
Send a message via AIM to Azzia Send a message via MSN to Azzia
This seems to be my issue right now. (I have changed things around and added new things but seems I am just making it worse)

Code:
Employee employee = new employee ( empName, hoursWorked, payRate);
It is a symbol error. I am going to research a little more to see if I can find the issue. Here is the rest of the code.

Code:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package payrollprogram; /** * * @author MKAY */ import java.util.Scanner; public class Main { String empName; double payRate; double hoursWorked; // main method begins execution of Java application public void main(String args[]) { boolean stop = false; // controls if loop below is executed while (!stop) { // create Scanner to obtain input from command window Scanner input = new Scanner(System.in); System.out.print("Enter employee's name or stop to quit: "); // prompt for name String EmpName = input.nextLine(); // read employee's name entered if (EmpName.equals("stop")) { System.out.println("This program has ended successfully."); stop = true; input.close(); break; } else { double PayRate; // First number multiplied double HoursWorked; // Second number multiplied double total; // Total of PayRate * HoursWorked System.out.print("Enter the pay rate per hour of the employee: "); // prompt for rate PayRate = input.nextDouble(); // read payrate of employee while (PayRate <= 0) // Validate for positive number { System.out.println(); System.out.println("Pay rate must be a positve number. "); System.out.print("Please enter pay rate per hour again: "); PayRate = input.nextDouble(); System.out.println(); } System.out.print("Enter the employee's hours worked this pay week: "); // prompt for Hours HoursWorked = input.nextDouble(); while (HoursWorked <= 0) // validate for positive number { System.out.println(); System.out .println("Hours worked must be a positive number. "); System.out.print("Please enter hours worked this pay week again: "); HoursWorked = input.nextDouble(); //read hourly rate of pay System.out.println(); } Employee employee = new employee ( empName, hoursWorked, payRate); System.out.printf( "Employee Name: %s, Weekly pay is $%d%n", employee.empName, employee.getWeeklyPay() ); // total = (double) PayRate * HoursWorked; // Multiply PayRate by HoursWorked // System.out.println(); // System.out.println("Employee: " + EmpName); //display name // System.out.println("Number of hours worked this pay week: " + HoursWorked); //display hours worked // System.out.printf("Employee's Pay: $%,.2f\n", total); //display pay rate // System.out.println(); // System.out.println(); } // end else } //end while } // end main } // end class class Employee { String empName; double hoursWorked; double payRate; double total; public void Employee (String name, double hours, double rate){ this.empName = name; this.hoursWorked = hours; this.payRate = rate; computeWeeklyPay(); } private void computeWeeklyPay() { total = (double) hoursWorked * (double) payRate; } public double getWeeklyPay(){ return total; } }
Reply With Quote