Payroll Program Assistance

I need help with my payroll program which is for my Java class. The assignment is: Modify the payroll program so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within the class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate.
With the program that I have below, I'm getting <indentier> expected
weeklyPay.calculatePay( rate, hours );
Help is needed as soon as possible because it is due today.
import java.util.Scanner;
public class Payroll3
Employee weeklyPay = new Employee();
weeklyPay.calculatePay( rate, hours );
class Employee
double rate;
double hours;
double pay;
private String employeeName;
public Employee( String name )
employeeName = name;
public void setEmployeeName( String name )
employeeName = name;
public String getEmployeeName()
return employeeName;
public static double calculatePay( double rate, double hours )
Scanner input = new Scanner( System.in );
System.out.print( "Enter employee name or stop to quit: " );
employeeName = input.nextLine();
while ( !employeeName.equals("stop") )
System.out.printf( "Enter %s's hourly rate: ", employeeName );
rate = input.nextDouble();
System.out.printf( "Enter %s's number of hours worked: ", employeeName );
hours = input.nextDouble();
pay = rate*hours;
System.out.printf( "%s's payment for the week is $%.2f\n", employeeName, pay );
System.out.println();
System.out.print( "Enter employee name or stop to quit: " );
employeeName = input.next();
System.out.println();
}

weeklyPay.calculatePay( rate, hours );What are rate and hours?
Before you answer, no they are not available in your Payroll3 class becuase you declared them in the Employee class.

Similar Messages

  • Payroll Program - please help

    I have a Java assignment due this Sunday, and I'm lost. I'm completely new to Java and this is only the second thing I've tried so far, so bear with me please, and don't laugh. :)
    This is the assignment:
    +"Create a non-GUI based Java application that calculates weekly pay for an+
    +employee. The application should display text that requests the user input the name+
    +of the employee, the hourly rate, and the number of hours worked for that week. The+
    +application should then print out the name of the employee and the weekly pay+
    +amount. In the printout, display the dollar symbol ($) to the left of the weekly pay+
    +amount and format the weekly pay amount to display currency."+
    In my chapter it talks about how to write a program that adds integers, so I tried to emulate that example but instead make it multiply. I wasn't sure how to do the employee's name, there is an explanation on printing lines of text, but not inputing and displaying text, only numbers. So for the employee's name I did some guesswork (for the data type declaration, etc), so I have no idea if that's right, (or if any of this is for that matter). I also don't know how to make it display the dollar symbol.
    Here is what I did so far:
    // Payroll Program Part 1
    import java.util.Scanner; // program uses class Scanner
    public class Multiplication
       // main method begins execution of Java application
       public static void main( String args[] )
          // create Scanner to obtain input from command window
          Scanner input = new Scanner( System.in );
          String name; // employee name to display
          int number1; // first number to multiply
          int number2; // second number to multiply
          int product; // product of number1 and number2
          System.out.print( "Enter employee name: "); // prompt
          name = input.nextString (); // read employee name from user
          System.out.print( "Enter hourly rate: " ); // prompt
          number1 = input.nextInt(); // read first number from user
          System.out.print( "Enter hours worked: " ); // prompt
          number2 = input.nextInt(); // read second number from user
          product = number1 * number2; // multiply numbers
          System.out.println( "Employee \n", name): // display employee name
          System.out.printf( "Weekly pay is %d\n", product ); // display product
       } // end method main
    } // end class MultiplicationKnow that I'm not asking anyone to do my homework for me, I just need some direction. I don't know what I'm doing, my teacher isn't helping and I'm not getting anything out of my chapters. Any assistance would be appreciated.

    newark wrote:
    You don't know how to print the $ symbol? Your code shows that you know how to print with System.out.println()...all that's left is finding the $ symbol on the keyboard...
    So what exactly is your problem? You say you don't know if your code is right. I have a suggestion...*run* your code and see if it works. If it works, it's right. If not, then come back here and let us know what it does do, including any exact error messages you might get.It's not easy to detect sarcasm over the Internet. Seriously I didn't think it would be that simple, but I just added the symbol, so now it says +"Weekly pay is $%d\n"+
    I don't know if that's in there right.
    Also, I tried to compile the program, and it found four errors, I fixed a couple (changed : to ; and apparently the public class name has to be the same as the file name, so now its public class Payroll1), but there are two others mistakes I made, both of which were my attempt at trying to include the program request the input and display the output for the employee name.
    They are both "cannot find symbol" errors, the first one is input.*nextString ()*; and the second is System.out.*println*
    So my guess at replacing int with "String" was wrong, and println is wrong. I'm going to try something else.

  • Help with Payroll program

    Hello I need help with the following code for a Payroll program.
    //CheckPoint: Payroll Program Part 3
    //Java Programming IT215
    //Arianne Gallegos
    //05/02/2007
    //Payroll3.java
    //Payroll program that calculates the weekly pay for an employee.
    import java.util.Scanner; // program uses class Scanner
    public class Payroll3
         private string name;
         private double rate;
         private double hours;
         // Constructor to store Employee Data
         public EmployeeData( String nameOfEmployee, double hourlyRate, double hoursWorked )
              name = nameOfEmployee;
              rate = hourlyRate;
              hours = hoursWorked;
         } // end constructor
    } //end class EmployeeData
       // main method begins execution of java application
       public static void main( String args[] )
          System.out.println( "Welcome to the Payroll Program! " );
          boolean quit = false; // This flag will control whether we exit the loop below
          // Loop until user types "quit" as the employee name:
          while (!quit)
           // create scanner to obtain input from command window
            Scanner input = new Scanner ( System.in );
            System.out.println();  // outputs a blank line
            System.out.print( "Please enter the employee name or quit to terminate program: " );
            // prompt for and input employee name
            String nameOfEmployee = input.nextLine(); // read what user has inputted
            if ( nameOfEmployee.equals("quit")) // Check whether user indicated to quit program
              System.out.println( "Program has ended" );
              quit = true;
    else
              // User did not indicate to stop, so continue reading info for this iteration:
              float hourlyRate; // first number to multiply
              float hoursWorked; // second number to multiply
              float product; // product of hourlyRate and hoursWorked
              System.out.print( "Enter hourly rate: " ); // prompt
              hourlyRate = input.nextFloat(); // read first number from user
              while (hourlyRate <= 0) // prompt until a positive value is entered
                 System.out.print( "Hourly rate must be a positive value. " +
                   "Please enter the hourly rate again: " ); // prompt for positive value for hourly rate
                  hourlyRate = input.nextFloat(); // read first number again
              System.out.print( "Enter hours worked: " ); // prompt
              hoursWorked = input.nextFloat(); // read second number from user
              while (hoursWorked <= 0) // prompt until a positive value is entered
                 System.out.print( "Hours worked must be a positive value. " +
                   "Please enter the hours worked again: " ); // prompt for positive value for hours worked
                  hoursWorked = input.nextFloat(); // read second number again
              product = (float) hourlyRate * hoursWorked; // multiply the hourly rate by the hours worked
              // Display output for this iteration
              System.out.println(); // outputs a blank line
              System.out.print( nameOfEmployee ); // display employee name
              System.out.printf( "'s weekly pay is: $%,.2f\n", product);  // display product
              System.out.println(); // outputs a blank line
          // Display ending message:
          System.out.println( "Thank you for using the Payroll program!" );
          System.out.println(); // outputs a blank line
       } // end method main
    } // end class Payroll3I am getting the following errors:
    Payroll3.java:18: invalid method declaration; return type required
    public EmployeeData( String nameOfEmployee, double hourlyRate, double hours
    Worked )
    ^
    Payroll3.java:28: class, interface, or enum expected
    public static void main( String args[] )
    ^
    Payroll3.java:33: class, interface, or enum expected
    boolean quit = false; // This flag will control whether we exit the loop b
    elow
    ^
    Payroll3.java:36: class, interface, or enum expected
    while (!quit)
    ^
    Payroll3.java:42: class, interface, or enum expected
    System.out.println(); // outputs a blank line
    ^
    Payroll3.java:43: class, interface, or enum expected
    System.out.print( "Please enter the employee name or quit to terminate p
    rogram: " );
    ^
    Payroll3.java:45: class, interface, or enum expected
    String nameOfEmployee = input.nextLine(); // read what user has inputted
    ^
    Payroll3.java:48: class, interface, or enum expected
    if ( nameOfEmployee.equals("quit")) // Check whether user indicated to q
    uit program
    ^
    Payroll3.java:51: class, interface, or enum expected
    quit = true;
    ^
    Payroll3.java:52: class, interface, or enum expected
    ^
    Payroll3.java:57: class, interface, or enum expected
    float hoursWorked; // second number to multiply
    ^
    Payroll3.java:58: class, interface, or enum expected
    float product; // product of hourlyRate and hoursWorked
    ^
    Payroll3.java:60: class, interface, or enum expected
    System.out.print( "Enter hourly rate: " ); // prompt
    ^
    Payroll3.java:61: class, interface, or enum expected
    hourlyRate = input.nextFloat(); // read first number from user
    ^
    Payroll3.java:64: class, interface, or enum expected
    while (hourlyRate <= 0) // prompt until a positive value is entered
    ^
    Payroll3.java:68: class, interface, or enum expected
    hourlyRate = input.nextFloat(); // read first number again
    ^
    Payroll3.java:69: class, interface, or enum expected
    ^
    Payroll3.java:72: class, interface, or enum expected
    hoursWorked = input.nextFloat(); // read second number from user
    ^
    Payroll3.java:75: class, interface, or enum expected
    while (hoursWorked <= 0) // prompt until a positive value is entered
    ^
    Payroll3.java:79: class, interface, or enum expected
    hoursWorked = input.nextFloat(); // read second number again
    ^
    Payroll3.java:80: class, interface, or enum expected
    ^
    Payroll3.java:86: class, interface, or enum expected
    System.out.println(); // outputs a blank line
    ^
    Payroll3.java:87: class, interface, or enum expected
    System.out.print( nameOfEmployee ); // display employee name
    ^
    Payroll3.java:88: class, interface, or enum expected
    System.out.printf( "'s weekly pay is: $%,.2f\n", product); // display
    product
    ^
    Payroll3.java:89: class, interface, or enum expected
    System.out.println(); // outputs a blank line
    ^
    Payroll3.java:91: class, interface, or enum expected
    ^
    Payroll3.java:96: class, interface, or enum expected
    System.out.println(); // outputs a blank line
    ^
    Payroll3.java:98: class, interface, or enum expected
    } // end method main
    ^
    The problem I am having is getting the constructor to work with the rest of the program can someone please point out to me how to correct this. I have read my textbook as well as tutorials but I just don't seem to get it right. Please help.
    P.S. I have never taken a programming class before so please be kind.

    Ok, I changed the name of the constructor:
    //CheckPoint: Payroll Program Part 3
    //Java Programming IT215
    //Arianne Gallegos
    //04/23/2007
    //Payroll3.java
    //Payroll program that calculates the weekly pay for an employee.
    import java.util.Scanner; // program uses class Scanner
    public class Payroll3
         private string name;
         private float rate;
         private float hours;
         // Constructor to store Employee Data
         public void Payroll3( string nameOfEmployee, float hourlyRate, float hoursWorked )
              name = nameOfEmployee;
              rate = hourlyRate;
              hours = hoursWorked;
         } // end constructor
    } //end class EmployeeData
       // main method begins execution of java application
       public static void main( String args[] )
          System.out.println( "Welcome to the Payroll Program! " );
          boolean quit = false; // This flag will control whether we exit the loop below
          // Loop until user types "quit" as the employee name:
          while (!quit)
           // create scanner to obtain input from command window
            Scanner input = new Scanner ( System.in );
            System.out.println();  // outputs a blank line
            System.out.print( "Please enter the employee name or quit to terminate program: " );
            // prompt for and input employee name
            String nameOfEmployee = input.nextLine(); // read what user has inputted
            if ( nameOfEmployee.equals("quit")) // Check whether user indicated to quit program
              System.out.println( "Program has ended" );
              quit = true;
    else
              // User did not indicate to stop, so continue reading info for this iteration:
              float hourlyRate; // first number to multiply
              float hoursWorked; // second number to multiply
              float product; // product of hourlyRate and hoursWorked
              System.out.print( "Enter hourly rate: " ); // prompt
              hourlyRate = input.nextFloat(); // read first number from user
              while (hourlyRate <= 0) // prompt until a positive value is entered
                 System.out.print( "Hourly rate must be a positive value. " +
                   "Please enter the hourly rate again: " ); // prompt for positive value for hourly rate
                  hourlyRate = input.nextFloat(); // read first number again
              System.out.print( "Enter hours worked: " ); // prompt
              hoursWorked = input.nextFloat(); // read second number from user
              while (hoursWorked <= 0) // prompt until a positive value is entered
                 System.out.print( "Hours worked must be a positive value. " +
                   "Please enter the hours worked again: " ); // prompt for positive value for hours worked
                  hoursWorked = input.nextFloat(); // read second number again
              product = (float) hourlyRate * hoursWorked; // multiply the hourly rate by the hours worked
              // Display output for this iteration
              System.out.println(); // outputs a blank line
              System.out.print( nameOfEmployee ); // display employee name
              System.out.printf( "'s weekly pay is: $%,.2f\n", product);  // display product
              System.out.println(); // outputs a blank line
          // Display ending message:
          System.out.println( "Thank you for using the Payroll program!" );
          System.out.println(); // outputs a blank line
       } // end method main
    } // end class Payroll3I still get the following error codes:
    C:\IT215\Payroll3>javac Payroll3.java
    Payroll3.java:28: class, interface, or enum expected
    public static void main( String args[] )
    ^
    Payroll3.java:33: class, interface, or enum expected
    boolean quit = false; // This flag will control whether we exit the loop b
    elow
    ^
    Payroll3.java:36: class, interface, or enum expected
    while (!quit)
    ^
    Payroll3.java:42: class, interface, or enum expected
    System.out.println(); // outputs a blank line
    ^
    Payroll3.java:43: class, interface, or enum expected
    System.out.print( "Please enter the employee name or quit to terminate p
    rogram: " );
    ^
    Payroll3.java:45: class, interface, or enum expected
    String nameOfEmployee = input.nextLine(); // read what user has inputted
    ^
    Payroll3.java:48: class, interface, or enum expected
    if ( nameOfEmployee.equals("quit")) // Check whether user indicated to q
    uit program
    ^
    Payroll3.java:51: class, interface, or enum expected
    quit = true;
    ^
    Payroll3.java:52: class, interface, or enum expected
    ^
    Payroll3.java:57: class, interface, or enum expected
    float hoursWorked; // second number to multiply
    ^
    Payroll3.java:58: class, interface, or enum expected
    float product; // product of hourlyRate and hoursWorked
    ^
    Payroll3.java:60: class, interface, or enum expected
    System.out.print( "Enter hourly rate: " ); // prompt
    ^
    Payroll3.java:61: class, interface, or enum expected
    hourlyRate = input.nextFloat(); // read first number from user
    ^
    Payroll3.java:64: class, interface, or enum expected
    while (hourlyRate <= 0) // prompt until a positive value is entered
    ^
    Payroll3.java:68: class, interface, or enum expected
    hourlyRate = input.nextFloat(); // read first number again
    ^
    Payroll3.java:69: class, interface, or enum expected
    ^
    Payroll3.java:72: class, interface, or enum expected
    hoursWorked = input.nextFloat(); // read second number from user
    ^
    Payroll3.java:75: class, interface, or enum expected
    while (hoursWorked <= 0) // prompt until a positive value is entered
    ^
    Payroll3.java:79: class, interface, or enum expected
    hoursWorked = input.nextFloat(); // read second number again
    ^
    Payroll3.java:80: class, interface, or enum expected
    ^
    Payroll3.java:86: class, interface, or enum expected
    System.out.println(); // outputs a blank line
    ^
    Payroll3.java:87: class, interface, or enum expected
    System.out.print( nameOfEmployee ); // display employee name
    ^
    Payroll3.java:88: class, interface, or enum expected
    System.out.printf( "'s weekly pay is: $%,.2f\n", product); // display
    product
    ^
    Payroll3.java:89: class, interface, or enum expected
    System.out.println(); // outputs a blank line
    ^
    Payroll3.java:91: class, interface, or enum expected
    ^
    Payroll3.java:96: class, interface, or enum expected
    System.out.println(); // outputs a blank line
    ^
    Payroll3.java:98: class, interface, or enum expected
    } // end method main
    ^
    27 errors
    Any other suggestions?

  • Employee payroll program problems

    I have done good so far but now im stuck and lost on how to take my program to the next step, kids got sick and i missed like a week of school so im behind. I am suppose to modify the Payroll Program so that it uses a class to store and retrieve the employee?s name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate. I am lost on the bold part..
    here is what I have:
    //Calculates weekly pay for an employee
    import java.util.Scanner; // program uses class Scanner
         public class BeemansPayroll
         private double rate;
         private double hours;
         private String name;
         //Used to save info
    public BeemansPayroll(String Name, double PayRate, double Hours)
         String name = Name;
         double rate = PayRate;
         double hours = Hours;
    private static void Quit()
    System.out.println("Thank You for using Beeman's Payroll");
    System.exit(0);
    // main method begins execution of Java application
    public static void main(String args[])
    // create Scanner to obtain input from command window
    Scanner input = new Scanner(System.in);
    String name = "";
    do {
    System.out.print("Enter Employee Name or stop to quit: ");
    // prompt for name
    name = input.next(); // get name
              if (name.equals("stop"))
    System.out.println("Thank You for using Beeman's Payroll");
    Quit();
    } //end if
    else
    double PayRate;
    double Hours;
    double Pay;
         System.out.print("Please enter Employee payrate:$ "); // prompt
         PayRate = input.nextDouble(); // read first number from user
              while (PayRate <= 0)
                        System.out.println ("Invalid amount, Payrate must be positive");
                        System.out.print("Please enter valid payrate:$ ");
                        PayRate = input.nextDouble();
                   } //end if      
    System.out.print("Please enter Employee hours: "); // prompt
    Hours = input.nextDouble(); // read second number from user
                             while (Hours <= 0)
                        System.out.println ("Invalid amount, Hours must be positive");
                        System.out.print("Please enter hours worked: ");
                        Hours = input.nextDouble();
                   } //end if
    Pay = PayRate * Hours; // multiply numbers
    System.out.printf("Employee Pay for the week %s, is $%.2f\n", name,
    (PayRate * Hours)); // display product
    } //end else
    }while (!name.equals("stop"));
    Quit();
    } // end method main
    } // end class Beeman's Payroll

    john774077 wrote:
    Like I said, I am lost, with all that is going on I have done the reading 4 times , Then try reading a different source such as the Sun Java tutorials. They are excellent and there is no substitute to your reading and learning. We can help you debug an error in your code, but we are not a tutorial service nor a homework production service. Note also that we are all volunteers.
    on top of kids getting sick and taking three algebra all at once. I advice you to not go on and on about this. This is not our problem and won't affect how or if someone helps you. If anything continued mention of this will turn many away who would otherwise help you.
    How or where do I go about breaking it down?You are redeclaring the variables in your constructor, i.e.,:
    String name = Name;  // don't do thisDon't do this because you'll never change the class's name variable this way. Instead in the constructor do something like this for each variable:
    name = Name;or
    this.name = Name;Later you will need to read up on Java naming conventions.
    As for creating the method, you should read up on method creation in your text book or tutorial. That'll give you a better explanation than we can, I think.

  • Hr payroll program

    How to write hr payroll programe can any body help me please
    <THREAD LOCKED. Please read the [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] to discover why>
    Edited by: Mike Pokraka on Aug 12, 2008 2:57 PM

    Hi,
    go through the following Blog..
    The specified item was not found.
    Check this -
    looping payroll results using pnpce ldb
    Regards.
    Eshwar.

  • I need to install version 22 - nothing higher until 27 is available as my payroll program will not run. How do I install version 22 and not the most recent ver

    I need to install version 22. This is under the guidance of my payroll provider. The program will not work until version 27 comes out. I do not need help solving the problem with the payroll program, I just want to install version 22 of Firefox.

    Firefox 27.0 is in Beta at moment until February 4 release.
    You would be better off trying to use wither the User Agent Switcher extension or ua-site-switch extension to try a fool this one site or to use the portable Firefox 22.0 just for this one site.
    https://addons.mozilla.org/en-US/firefox/addon/user-agent-switcher/
    https://addons.mozilla.org/en-US/firefox/addon/ua-site-switch/
    You should not switch to using 22.0 only due to known potential vulnerabilities that is fixed in newer versions like the current Fx 26.0.
    The Portable Firefox is a self contained program as it will not interfere with your current Firefox 26.0 install. It can even be used completely on a usb flash drive. http://sourceforge.net/projects/portableapps/files/Mozilla%20Firefox%2C%20Portable%20Ed./Mozilla%20Firefox%2C%20Portable%20Edition%2022.0/ and pick your language.
    I posted a ink to portable Firefox 22.0 as their homepage currently only links to the current 26.0 and 24.2.0esr on http://portableapps.com/apps/internet/firefox_portable

  • Payroll program

    I have a question. I have to write a payroll program that calculates and prints the monthly paycheck for an employee with 6 deductions coming out, fed and state tax, social, medicare/aid, pension and health.
    I need to structure it so it prompts the user to enter their gross pay amount and employee name, output stored in a file and output formatted to 2 places. I've tried finding other programs that would be similar to this so that I can use it as a guide to writing this one that I need to complete but I have not been able to find anything that gives me some solid help. Does anybody have a program I could look at to use as a guide for writing this or links that would show me how to proceed on structuring this. I'm lost at the moment and this is my last hope. Thanks for the guidance.

    import java.util.Scanner;
    import javax.swing.JOptionPane;
    public class payrollapplication /**
    * @param args the command line arguments
    public static void main(String[] args) {
           Scanner scan = new Scanner(System.in);//declare and initialize variables
    String employeeName;
           Double federalTax;
           Double stateTax;
           Double socialTax;
           Double medicareMedicaid;
           Double pension;
           Double deductions;
           Double netPay;
           int healthInsurance;
           int grossAmount;
           int netAmount;
           String inputStr;
           String outputStr;
           federalTax = .15;
           stateTax = .035;
           socialTax = .0575;
           medicareMedicaid = .0275;
           pension = .05;
           healthInsurance = 75;//input employee name
    employeeName = JOptionPane.showInputDialog("Enter Employee Name:"); //input gross amount
    inputStr = JOptionPane.showInputDialog("Enter Gross Amount:");
           grossAmount = Integer.parseInt(inputStr);//figure Federal tax amount
    federalTax = federalTax * grossAmount;//figure State tax amount
    stateTax = stateTax * grossAmount;//figure Social security tax
    socialTax = socialTax * grossAmount;//figure Medicare/Medicaid tax
    medicareMedicaid = medicareMedicaid * grossAmount;//figure Pension amount
    pension = pension * grossAmount;//figure total deduction for Net amount
    deductions = pension + medicareMedicaid + socialTax + stateTax + federalTax;//figure Net pay
    netPay = deductions - grossAmount;//Configure data for the output string
    outputStr = "Employee Name: " + employeeName + "/n"
                   + "Gross Amount: $"
                   + String.format("%.2f", grossAmount)+ "/n"
                   + "Federal Tax: $"
                   + String.format("%.2f", federalTax)+ "/n"
                   + "State Tax: $"
                   + String.format("%.2f", stateTax)+ "/n"
                   + "Social Security Tax: $"
                   + String.format("%.2f", socialTax)+ "/n"
                   + "Medicare/Medicaid Tax: $"
                   + String.format("%.2f", medicareMedicaid)+ "/n"
                   + "Pension Plan: $"
                   + String.format("%.2f", pension)+ "/n"
                   + "Health Insurance: $"
                   + String.format("%.2f", healthInsurance)+ "/n"
                   + "Net Pay: $"
                   + String.format("%.2f", netPay);
           JOptionPane.showMessageDialog(null, outputStr, "Payroll Breakdown", JOptionPane.INFORMATION_MESSAGE);I am getting an error when I run this application. It says this: Exception in thread "main" java.util.IllegalFormatConversionException: f != java.lang.Integer
    at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:3992)
    at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2721)
    at java.util.Formatter$FormatSpecifier.print(Formatter.java:2666)
    at java.util.Formatter.format(Formatter.java:2432)
    at java.util.Formatter.format(Formatter.java:2366)
    at java.lang.String.format(String.java:2770)
    at payrollapplication.main(payrollapplication.java:76)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 10 seconds)
    Thanks again.
    Edited by: Nightryno on Oct 10, 2008 8:35 PM
    Edited by: Nightryno on Oct 10, 2008 9:00 PM

  • Payroll Program Part 3 (confused)

    Okay, I'm sure you guys are sick of me by now. :-)
    This is the last part of an assignment that's supposed to calculate an employee's weekly pay, these are the requirements for this phase:
    Payroll Program Part 3:
    Modify the Payroll Program so that it uses a class to store and retrieve the employee's
    name, the hourly rate, and the number of hours worked. Use a constructor to initialize the
    employee information, and a method within that class to calculate the weekly pay. Once
    stop is entered as the employee name, the application should terminate.
    So I wrote the separate class:
    // Employee class stores and retrieves employee information
    import java.util.Scanner; // program uses class scanner
    public class Employee1
       // instance fields
       private double rate;
       private double hours;
       private String employeeName;
       // class constructor
       public Employee1()
          rate = 0.0;
          hours = 0.0;
          employeeName = "";
       } // end class Employee1 constructor
       // set rate
       public void setrate(double rate)
          rate = rate;
       } // end method setrate
       // get rate
       public double getrate()
          return rate;
       } // end method getrate
       // set hours
       public void sethours(double hours)
          hours = hours;
       } // end method sethours
       // get hours
       public double gethours()
          return hours;
       } // end method gethours
       // set employee name
       public void setemployeeName(String employeeName)
          employeeName = employeeName;
       } // end method setemployeeName
       // get employee name
       public String getemployeeName()
          return employeeName;
       } // end method getemployeeName
       // calculate and return weekly pay
       public double calculateWeeklyPay()
          return rate * hours; // display multiplied value of rate and hours
       } // end method calculateWeeklyPay
    } // end class Employee1...and modified the original program:
    // Payroll Program Part 3
    // Employee1 object used in an application
    import java.util.Scanner; // program uses class Scanner
    public class Payroll3
       // main method begins execution of Java application
       public static void main( String args[] )
          // create and initialize an Employee1 object     
          Employee1 employee = new Employee1(); // invokes Employee1 constructor
          employee.setrate();
          employee.sethours();
          Double weeklyPay = employee.calculateWeeklyPay();
          // create Scanner to obtain input from command window
          Scanner input = new Scanner( System.in );
          String employeeName = ""; // employee name to display
          Double rate; // first number to multiply
          Double hours; // second number to multiply
          Double weeklyPay; // product of rate and hours
          // loop until 'stop' read from user
          while( employeeName.equals("stop") )
             System.out.print( "Enter employee name or 'stop' to quit: "); // prompt
             employeeName = input.next (); // read employee name from user
             System.out.print( "Enter hourly rate: " ); // prompt
             rate = input.nextDouble(); // read first number from user
             // check if hourly rate is positive number
             if( rate <= 0 )
                System.out.print( "Enter a positive amount" );
                System.out.print( "Enter hourly rate: " ); // prompt
                rate = input.nextDouble(); // read first number from user
             } // end if
             System.out.print( "Enter hours worked: " ); // prompt
             hours = input.nextDouble(); // read second number from user
             // check if hours worked is positive number
             if( hours <= 0 )
                System.out.print( "Enter a positive amount" );
                System.out.print( "Enter hours worked: " ); // prompt
                hours = input.nextDouble(); // read second number from user
             } // end if
             weeklyPay = rate * hours; // multiply numbers
             System.out.printf( "Employee \n", employeeName); // display employee name
             System.out.printf( "Weekly pay is $%d\n", weeklyPay ); // display weekly pay
          } // end while
       } // end method main
    } // end class Payroll3I managed to compile the separate class just fine, but when I tried to compile Payroll3 I got these [three error messages|http://img150.imageshack.us/img150/3919/commandpromptrl9.jpg].
    I think I have an idea of what I did wrong, but I'm not sure what to change. I tried to emulate the code from some examples in my chapters and online but I'm a little in the dark about how these to files are actually supposed to work together.
    Also, the requirements say the program should end when 'stop' is entered as the employee name, I don't know if that applies to what I already have in Payroll3 or if I should use a sentinel controlled loop again in Employee1. I tried that and I got a whole host of error messages (probably did it wrong) so I just removed it.
    I'm going to play around with this a little more, I'm reluctant to change anything in my separate class since I managed to compile it, so I'm going to try some different things with Payroll3.
    If anyone has any suggestions I would greatly appreciate it, I'm a total newbie here so don't hesitate to state the obvious, it might not be so obvious to me (sorry for the lengthy post).
    Edited by: Melchior727 on Apr 22, 2008 11:21 AM
    Edited by: Melchior727 on Apr 22, 2008 11:23 AM

    employee.setrate();
    employee.sethours();First of all, your Employee1 class' setrate() and sethours() method both requires a parameter of type double.
    // loop until 'stop' read from user
    while( employeeName.equals("stop") )
    System.out.print( "Enter employee name or 'stop' to quit: "); // prompt
    employeeName = input.next (); // read employee name from userIf you want the while loop to stop when "stop" is entered, then change the condition to:
    while (!(employeeName.equals("stop))){code}
    This way the loop will perform whatever you tell it to do when it's NOT "stop".
    Also, take the prompt statements and paste them once outside the while loop, and a second time at the end of the loop:
    <example>
    == prompt for reply
    == while()
    == {
    == ....
    == prompt again
    == }
    <example>
    Fix those problems first and see how it goes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • HR- Attendance Problem related to payroll program

    Hello Experts,
                        I have created the zreport from attendance in HR-payroll ( Tcode: PT91_ATT ). Actually I have copy the whole satandard report code (with Tcode: PT91_ATT ) to my zreport for the customized requirement. Report is executing fine  with dispalying the employee code(PERNR), name of employee (BNAME), and the date wise display like 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31.
    My requirement is to add the three fields more in the same printing logic i.e. Total no of Present(P), Total no of Leaves(L), Total no of Absents(A) with in the same report. I have done some changes but they are not executing. Can you please suggest how it can be done. If possible do suggest with code of program please.
    Regards,
    Akg

    Hi
    Unfortunately, I don't believe in spoon feeding and hence not be posting the source code here.
    I believe I have given enough information as to what can be used to get the report developed.
    Further to this, let me explain you the logic to be followed in detail -
    Steps to be followed -
    1. Use Logical DB PNP & node PERNR of it.
    2. Loop through all the personnel numbers between GET PERNR... END-OF-SELECTION
    3. Query time data for each employee using the function module HR_FORMS_TIM_GET_B2_RESULTS. First, loop through the internal table FT_PSP to get the "SHIFT" and "Weekly off" here and fill the day slots.
    4. Now that you have got the weekly off's of the employee check for other possible entries such as PRESENCE, ABSENCE(CL,SL,PL et al.) which can be found in the internal table FT_TP of B2 cluster.
    5.Finally, when you have data for entire month count the related PRESENCE & ABSENCE and any other things that you would like to have in your output.
    Let me know, if you need anything else. Perhaps, not the source code.
    Regards,
    Rupesh Mhatre
    Edited by: rumhat on Mar 24, 2011 2:32 PM
    Edited by: rumhat on Mar 24, 2011 2:33 PM

  • Programming assistance

    Hi all,
    I need some help hopefully before Sun evening... I have to modify my Inventory program to have an Add, Delete and a search button simple enough.. Well Im new to Java programming and have been limping my way along from day one I have a C+ and need a C- so a little leeway.
    Could any one assist me on the easiest way to accomplish the task above even if it is just the search button that I get help with its better then nothing... So My DVDGUI looks like this;
    //DVDGUI.java
    import java.util.Arrays;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.ImageIcon;
    public class DVDGUI extends JFrame
    //Private Variables
    private GridBagLayout layout = new GridBagLayout();
    private GridBagConstraints constraints = new GridBagConstraints();
    //Private data from prior assignments
         private DVD [] dvd;
         private int index;
    // Labels
    private JLabel logoLabel;
    private JLabel nameLabel;
    private JLabel idLabel;
    private JLabel titleLabel;
    private JLabel unitsLabel;
    private JLabel priceLabel;
    private JLabel valueLabel;
    private JLabel feeLabel;
    private JLabel totalLabel;
    // Text Fields for displaying or editing
    private JTextField nameText;
    private JTextField idText;
    private JTextField titleText;
    private JTextField unitsText;
    private JTextField priceText;
    private JTextField valueText;
    private JTextField feeText;
    private JTextField totalText;
    private JTextField searchText;
    //Buttons
    private JButton firstButton; //To move to first element in the array
    private JButton nextButton; //To move to next element in the array
    private JButton previousButton; //To again move to next element in the array
    private JButton lastButton; //To move again to first element in the array
    private JButton addButton; //To add a DVD to array
    private JButton deleteButton; //To delete a DVD from array
    private JButton modifyButton; //To modify an element
    private JButton saveButton; //To save the array
    private JButton searchButton; //To search the array
    //Constatnts
    private final static int LOGO_WIDTH = 4;
    private final static int LOGO_HEIGHT = 4;
    private final static int LABEL_HEIGHT = 1;
    private final static int LABEL_WIDTH = 1;
    private final static int TEXT_HEIGHT = 1;
    private final static int TEXT_WIDTH = LOGO_WIDTH - LABEL_WIDTH;
    private final static int BUTTON_HEIGHT = 1;
    private final static int BUTTON_WIDTH = 1;
    private final static int LABEL_START_ROW = LOGO_HEIGHT + LABEL_WIDTH + 1;
    private final static int LABEL_COLUMN = 0;
    private final static int TEXT_START_ROW = LABEL_START_ROW;
    private final static int TEXT_COLUMN = LABEL_WIDTH + 1;
    private final static int BUTTON_START_ROW = LABEL_START_ROW + 9*LABEL_HEIGHT;
    private final static int BUTTON_COLUMN = LABEL_COLUMN;
    private final static int SEARCH_START_ROW = BUTTON_START_ROW + 3;
    final static String EMPTY_ARRAY_MESSAGE = "Hit ADD to add a new DVD";
    //Constants
    private final static int FRAME_WIDTH = 325;//460
    private final static int FRAME_LENGTH = 350;//343
    private final static int FRAME_XLOC = 250;
    private final static int FRAME_YLOC = 100;
         //Constructors
    //Initialization constructor
         public DVDGUI( DVD dvdIn[] )
         //Pass the frame title to JFrame, set the IconImage
              super( "DVD Inventory" );
    setLayout( layout );
    //Copy the input array (dvdIn)
              setDVDArray( dvdIn );
    //Start the display with the first element of the array
              index = 0;
    //Build the GUI
    buildGUI();
    //Values
    updateAllTextFields();
         }//End constructor DVDGUI
    //Methods
    //Copy an input DVD array to the GUI's private DVD array variable
         private void setDVDArray( DVD dvdIn[] )
              dvd = new DVD[dvdIn.length];
              for(int i = 0;i < dvd.length;i++)
              //Create a DVD array element from the input array
                   dvd[i] = new DVD( dvdIn[i] );
    /*               dvd[i] = new DVD( dvdIn.title(), dvdIn[i].productNumber(),
                   dvdIn[i].productUnitsInStock(), dvdIn[i].productPrice()
    //System.out.println( dvdIn[i].toString() );
              }//End for
         }//End copyArray
    //A method for updating each of the GUI fields
         private void updateAllTextFields()
    if ( dvd.length > 0 ) //Then update the JTextField display
    //Update the product name text field
    nameText.setText( dvd[index].productName() );
    //Update the product id text field
    idText.setText( String.format( "%d", dvd[index].productNumber() ) );
         //Update the title text field
              titleText.setText( dvd[index].title() );
    //Update the units in stock text field
              unitsText.setText( String.format( "%d", dvd[index].productUnitsInStock() ) );
         //Update the price text field
              priceText.setText( String.format( "$%.2f" , dvd[index].productPrice() ));
    //Update the stock value text field
              valueText.setText( String.format( "$%.2f" , dvd[index].productValue() ));
    //Update the restocking fee text field
              feeText.setText( String.format( "$%.2f" , dvd[index].restockingFee() ));
    //Update the total value text field
              totalText.setText( String.format( "$%.2f" , DVD.productValue( dvd ) ));
    }//End if
    else //Put a special message in the fields
    //Update the product name text field
    nameText.setText( EMPTY_ARRAY_MESSAGE );
    //Update the product id text field
    idText.setText( EMPTY_ARRAY_MESSAGE );
         //Update the title text field
              titleText.setText( EMPTY_ARRAY_MESSAGE );
         //Update the units in stock text field
              unitsText.setText( EMPTY_ARRAY_MESSAGE );
         //Update the price text field
              priceText.setText( EMPTY_ARRAY_MESSAGE );
    //Update the stock value text field
              valueText.setText( EMPTY_ARRAY_MESSAGE );
    //Update the restocking fee text field
              feeText.setText( EMPTY_ARRAY_MESSAGE );
    //Update the total value text field
              totalText.setText( EMPTY_ARRAY_MESSAGE );
    }//End else
         }//End updateAllTextFields
    //Set the appropriate fields editable or uneditable
    private void setModifiableTextFieldsEnabled( Boolean state )
    //The DVD ID, title, units in stock, and price can all be set editable or uneditable
    idText.setEditable( state );
    titleText.setEditable( state );
    unitsText.setEditable( state );
    priceText.setEditable( state );
    }//End setModifiableTextFieldsEnabled
    //Button Handler Class - Handling Methods
    private class ButtonHandler implements ActionListener
         public void actionPerformed(ActionEvent event)
    if( event.getSource() == firstButton ) //First is pressed
              handleFirstButton();
    }//End if
    else if( event.getSource() == previousButton ) //Previous is pressed
              handlePreviousButton();
    }//End else if
    else if( event.getSource() == nextButton ) //Next button is pressed
              handleNextButton();
    }//End else if
    else if( event.getSource() == lastButton ) //Last button is pressed
              handleLastButton();
    }//End else if
         else if (event.getSource() == firstButton)
              handleFirstButton();
         }//end else if
    }//End method actionPerformed
         }//End class ButtonHandler
    //Display the first element of the DVD array
    private void handleFirstButton()
         //Set the index to the first element in the array
    index = 0;
    //Update and disable modification
              updateAllTextFields();
    setModifiableTextFieldsEnabled( false );
    }//End method handleFirstButton
    //Display the next element of the DVD array or wrap to the first
    private void handleNextButton()
         //Increment the index
         index++;
    //If index exceeds the last valid array element, wrap around to the first element of the array
    if ( index > dvd.length - 1 )
    index = 0;
    }//End if
    //Update and disable modification
              updateAllTextFields();
    setModifiableTextFieldsEnabled( false );
    }//End method handleNextButton
    private void handlePreviousButton()
         index--;
         if ( index < 0)
              index = dvd.length - 1;
         }// End if
         //Update and disable modification
              updateAllTextFields();
    setModifiableTextFieldsEnabled( false );
    }//End method handlePreviousButton
    private void handleLastButton()
         index--;
         if ( index < dvd.length - 1 )
              index = 2;
         }//End if
         //Update and disable modification
              updateAllTextFields();
    setModifiableTextFieldsEnabled( false );
    }//End method handleLastButton
    //TextField Handler Class - Handling Methods
    //The class for handling the events for the buttons
    //NOTE: You don't need this for Week Eight, but I'm including it for motivation on Week
    //Nine's assignment
    //Hope you dont mind me leaving thin in there
    private class TextFieldHandler implements ActionListener
    public void actionPerformed( ActionEvent event )
    //User pressed Enter in JTextField titleText
    if ( event.getSource() == idText )
    //handleIdTextField();
    }//End if
    //User pressed Enter in JTextField titleText
    else if ( event.getSource() == titleText )
    //handleTitleTextField();
    }//End else if
    //User pressed Enter in JTextField unitsText
    else if ( event.getSource() == unitsText )
    //handleUnitsTextField();
    }//End else if
    //User pressed Enter in JTextField priceText
    else if ( event.getSource() == priceText )
    //handlePriceTextField();
    }//End else if
    //User pressed Enter in JTextField searchText
    else if ( event.getSource() == searchText )
    //handleSearchButtonOrTextField();
    }//End else if
    }//End method actionPerformed
    }//End inner class TextFieldHandler
    //GUI Methods
    //Build GUI
    private void buildGUI()
    //Add the logo
    buildLogo();
    //Add the text fields and their labels
    buildLabels();
    buildTextFields();
    //Add the navigation and other buttons
    buildMainButtons();
    //Give some values to the fields
    updateAllTextFields();
    //Set some of the frame properties
              setSize( FRAME_LENGTH , FRAME_WIDTH );
              setLocation( FRAME_XLOC , FRAME_YLOC );
              setResizable( false );
              //pack();
              setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              setVisible( true );
    }//End buildGUI()
    //Add the logo to the JFrame
    private void buildLogo()
    constraints.weightx = 2;
    constraints.weighty = 1;
    logoLabel = new JLabel( new ImageIcon( "shamrock.jpg" ) );
    logoLabel.setText( "Lucky DVDs" );
    constraints.fill = GridBagConstraints.BOTH;
    addToGridBag( logoLabel, 2, 2, LOGO_WIDTH, LOGO_HEIGHT );
    //Create a vertical space
    addToGridBag( new JLabel( "" ), LOGO_HEIGHT + 1, 0, LOGO_WIDTH, LABEL_WIDTH );
    }//End method buildLogo
    //Build just the panel containing the text
    private void buildLabels()
    //Variables (for readability)
    int row = 0;
    int column = 0;
    int width = 0;
    int height = 0;
    column = LABEL_COLUMN;
    width = LABEL_WIDTH;
    height = LABEL_HEIGHT;
    constraints.weightx = 1;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.BOTH;
    //Create the name label and name text field
    nameLabel = new JLabel( "Product: " );
    nameLabel.setLabelFor( nameText );
    row = LABEL_START_ROW;
    addToGridBag( nameLabel, row, column, width, height);
    //Create the id label and id text field
    idLabel = new JLabel( "Product Id: " );
    idLabel.setLabelFor( idText );
    row += LABEL_HEIGHT;
    addToGridBag( idLabel, row, column, width, height);
    //Create the DVD title label and DVD title text field
    titleLabel = new JLabel( "Title: " );
    titleLabel.setLabelFor( titleText );
    row += LABEL_HEIGHT;
    addToGridBag( titleLabel, row, column, width, height);
    //Create the units in stock label and units in stock text field
              unitsLabel = new JLabel( "Units in Stock: " );
    unitsLabel.setLabelFor( unitsText );
    row += LABEL_HEIGHT;
    addToGridBag( unitsLabel, row, column, width, height);
    //Create the price label and price text field
              priceLabel = new JLabel( "Unit Price:" );
    priceLabel.setLabelFor( priceText );
    row += LABEL_HEIGHT;
    addToGridBag( priceLabel, row, column, width, height);
    //Create the value label and value text field
              valueLabel = new JLabel( "Product Value:" );
    valueLabel.setLabelFor( valueText );
    row += LABEL_HEIGHT;
    addToGridBag( valueLabel, row, column, width, height);
    //Create the fee label and fee text field
              feeLabel = new JLabel( "Restocking fee:" );
    feeLabel.setLabelFor( feeText );
    row += LABEL_HEIGHT;
    addToGridBag( feeLabel, row, column, width, height);
         //Create a vertical space
    row += LABEL_HEIGHT;
    addToGridBag( new JLabel( "" ), row, column, width, height );
    //Create the total value label and total value text field
              totalLabel = new JLabel( "Inventory Value:" );
    totalLabel.setLabelFor( totalText );
    row += LABEL_HEIGHT;
    addToGridBag( totalLabel, row, column, width, height);
    }//End method buildLabels()
    //Build containing textFields
    private void buildTextFields()
    //Variables
    int row = 0;
    int column = 0;
    int width = 0;
    int height = 0;
    column = TEXT_COLUMN;
    width = TEXT_WIDTH;
    height = TEXT_HEIGHT;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1;
    TextFieldHandler handler = new TextFieldHandler();
    nameText = new JTextField( "DVD" );
              nameText.setEditable( false );
    row = TEXT_START_ROW;
    addToGridBag( nameText, row , column, width, height );
    idText = new JTextField( "" );
              idText.setEditable( false );
    row += TEXT_HEIGHT;
    addToGridBag( idText, row , column, width, height );
    titleText = new JTextField( " " );
    titleText.addActionListener( handler );
              titleText.setEditable( false );
    row += TEXT_HEIGHT;
    addToGridBag( titleText, row , column, width, height );
    unitsText = new JTextField( " " );
    unitsText.addActionListener( handler );
              unitsText.setEditable( false );
    row += TEXT_HEIGHT;
    addToGridBag( unitsText, row , column, width, height );
    priceText = new JTextField( " " );
    priceText.addActionListener( handler );
              priceText.setEditable( false );
    row += TEXT_HEIGHT;
    addToGridBag( priceText, row , column, width, height );
    valueText = new JTextField( " " );
              valueText.setEditable( false );
    row += TEXT_HEIGHT;
    addToGridBag( valueText, row , column, width, height );
    feeText = new JTextField( " " );
              feeText.setEditable( false );
    row += TEXT_HEIGHT;
    addToGridBag( feeText, row , column, width, height );
    //Create a vertical space
    row += TEXT_HEIGHT;
    addToGridBag( new JLabel( " " ), row, column, width, height );
    totalText = new JTextField( "" );
              totalText.setEditable( false );
    row += TEXT_HEIGHT;
    addToGridBag( totalText, row , column, width, height );
    }//End method buildTextFields
    //Add the main buttons to the frame
    private void buildMainButtons()
    //Variables
    int row = 0;
    int column = 0;
    int width = 0;
    int height = 0;
    row = BUTTON_START_ROW;
    column = BUTTON_COLUMN;
    width = BUTTON_WIDTH;
    height = BUTTON_HEIGHT;
    constraints.weightx = 1;
    constraints.weighty = 0;
    //constraints.fill = GridBagConstraints.HORIZONTAL;
    ButtonHandler handler = new ButtonHandler();
    //Create a vertical space
    addToGridBag( new JLabel( "" ), row, 0, LOGO_WIDTH, LABEL_HEIGHT );
    firstButton = new JButton( "First" );
    firstButton.addActionListener( handler );
    row += LABEL_HEIGHT;
    addToGridBag( firstButton, row, column, width, height );
    previousButton = new JButton( "Previous" );
    previousButton.addActionListener( handler );
    column += BUTTON_WIDTH;
    addToGridBag( previousButton, row, column, width, height );
    nextButton = new JButton( "Next" );
    nextButton.addActionListener( handler );
    column += BUTTON_WIDTH;
    addToGridBag( nextButton, row, column, width, height );
    lastButton = new JButton( "Last" );
    lastButton.addActionListener( handler );
    column += BUTTON_WIDTH;
    addToGridBag( lastButton, row, column, width, height );
    }//End method buildMainButtons
    //Add a component to the grid bag
    // See Chapter 22, pp 1037 - 1046, Deital & Deital
    private void addToGridBag( Component component, int row, int column, int width, int height )
    //Set the upper-left corner of the component (gridx, gridy)
    constraints.gridx = column;
    constraints.gridy = row;
    //Set the number of rows and columns the componenet occupies
    constraints.gridwidth = width;
    constraints.gridheight = height;
    //Set the constraints
    layout.setConstraints( component, constraints );
    //Add the component to the JFrame
    add( component );
    }//End method addToGridBag
    } //End class DVDGUI
    Another thing is I have no idea where in this big list of code I need to write more code in order for the buttons to work. I was able to add buttons but they did nothing so I took them out. If anyone can help out that would be fantastic, if not its cool I will just do the best I can and get a second job to repay to take the class again :) No pressure right! Also please know Im not trying to have you all do my work, I just need guidence on where in this mess of text where I need to add more text.
    Thanks!
    Message was edited by: Me
    Greenbeer4me

    DvdRental class
    public class DvdRental {
         private String title;
         private int units;
         private double price;
         private String advisory;
         public DvdRental(String title, int units, double price
                   , String advisory) {
              this.title = title;
              this.units = units;
              this.price = price;
              this.advisory = advisory;
         public void setTitle(String dvdTitle) {
              title = dvdTitle;
         public void setUnits(int dvdUnits) {
              units = dvdUnits;
         public void setPrice(double dvdPrice) {
              price = dvdPrice;
         public void setAdvisory(String dvdAdvisory) {
              advisory = dvdAdvisory;
         public String getTitle() {
              return title;
         public int getUnits() {
              return units;
         public double getPrice() {
              return price;
         public String getAdvisory() {
              return advisory;
    }DvdList class
    import java.util.*;
    import javax.swing.*;
    public class DvdList extends AbstractListModel{
         private SortedSet model;
         public DvdList() {
              model = new TreeSet();
         public void add(DvdRental b) {
              model.add(b);
              fireContentsChanged(this,0,getSize());
         public void remove(DvdRental b) {
              model.remove(b);
              fireContentsChanged(this,0,getSize());
         public int getSize() {
              return model.size();
         public Object getElementAt(int index) {
              return model.toArray()[index];
         public void clear() {
              model.clear();
         public boolean contains(Object element) {
              return model.contains(element);
         public DvdRental find(String title) {
              for(DvdRental a : model) {
                   if(a.getTitle().equals(title))
                        return a;
              return null;
    }Now the swing part is left

  • Creating a program assistant

    does anyone know how to take an animated flash character and
    transform it into 1 of those annoying office assistant's that
    program's like microsoft word uses?? i have the character already
    drawn out and ready to be integrated into a piece of software that
    the company i work for uses.
    Any ideas would be greatly appreciated.
    :D

    Is this what you're looking for?
    http://www.microsoft.com/msagent/default.asp
    "Zaffer36" <[email protected]> wrote in
    message
    news:e9q28q$oj4$[email protected]..
    > does anyone know how to take an animated flash character
    and transform it
    into
    > 1 of those annoying office assistant's that program's
    like microsoft word
    > uses?? i have the character already drawn out and ready
    to be integrated
    into a
    > piece of software that the company i work for uses.
    >
    > Any ideas would be greatly appreciated.
    >
    > :D
    >

  • Vim and C++ programming assistance

    Hello,
    I would like to use vim for C++ programming. I know it is not an IDE, but I wonder what coding assistant vim could provide.
    I have omnicompletion installed via pacman and as described here:
    http://vim.wikia.com/wiki/VimTip1608
    kind of works, but if I have this:
    int main()
       std::
    Completion is started, and i.E. vector is suggested. But I have no #include <vector> ...
    Can vim be made aware of this?
    Also, I am looking through the web for vim C++ code assistance. I find a lot. There is ctags, csope. There are things which seem to work for C, but not for C++ ... I just do not know how to filter all this info.
    What are the state-of-the-art packages for:
    - Finding the decleration of a symbol
    - Finding the implementation of a function
    - Displaying the function prototype (arguments) while typing the arguments
    Thanks!
    Nathan

    darthaxul wrote:If your gonna be programming you must grab a better app such as medit, way easier config with mouse support also.
    Well, I couldn't disagree more with this comment If you want to be productive, try to forget about the mouse and learn to use the keyboard and the powerful editing capabilities of vim efficiently. I tried some IDEs (eclipse, kdevelop, netbeans) which had some nice features, but the editors were always lacking and they are too mouse oriented for my taste. Therefore I always kept coming back to vim.
    W.r.t. plugins, I do not really use many. Omnicompletion and ctags (and I have a background script running wich updates the tag file every minute) which I use regularly. With ctags you can find the declaration and implementation of symbols. And I think omnicomplete has some options for displaying the function prototype, like you want (I know I deactivated it, because for me it was too intrusive most of the time). I also have taglist installed, but I do not use it often.
    From the standard editing capabilities, what you should definitely look at is:
    - Define the indentation as you like it
    - Toggle highlighting of search terms on demand (I have this mapped on \s)
    - Use the "." command
    - Compile and jump to errors from within vim
    - Visual rectangle mode
    There are probably more, but these are the first that come to mind. If you really learn to use the extensive editing capabilities of vim, you probably will be equally efficient (or more) than with en IDE. After all, most of the time you are only editing.
    And to go to the "lacking aspects": what I really miss are refactoring tools, e.g. for changing the name of a class or a method of a class. This would be quite a useful addition and something where (some of) the IDEs have a clear advantage.
    Last edited by davvil (2009-06-05 09:38:52)

  • Payroll program for Mac?

    I've used Payroll Mate in the past on a PC. New to Mac, I'm finding it hard to locate a program I can download to Mac. Any suggestions?

    Good place to look for software:
    http://www.macupdate.com/
    And for free alternatives to some popular software packages:
    http://alternativeto.net/
    (If you see an ad there for something called MacKeeper, ignore it and on no account install it - it is malware.)

  • CJ20N Project Builder Validation Programming - Assistance requested

    This is a how-to request.  I am trying to validate user entry at save time in the CJ20N Project Builder (Project Systems).   The desire is to enforce that the project, wbs, and network company codes are all the same prior to saving a NEW project. 
    The problem I am having is on the scenario in which a user creates a new project by copying an existing project or standard template.  If the user changes the company code on one or more wbs before saving it,  the wbs table in abap memory prior to saving does not reflect this change.  The table is called CJ_BUF_PRPSxxx99999999 where xxx is the client number (mandt).
    Thus any attempts to loop at this table to validate the company code against the parent project are futile.
    I have contacted SAP on this  issue and they insist that it is not a bug.  I need an alternate solution.
    Any help would be appreciated.

    I solved this problem myself by stepping through the debugger between the user exit and the actual save routine.  I was able to find the correctly populated internal table to loop at.  It was called PSTAB.

  • Programming assistance reqd

    student trying to write java tic tac toe game, computer is "o" player ix "x". Computer overwrites "x" placed by player. Anythoughts to cure problem

    you could create a dimensional array to represent the board and when a player or user clicks on a position check to see whether it's been taken or not, if it isn't then update the array to indicate that it is taken now.

Maybe you are looking for