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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • 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?

  • 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.

  • 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 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.

  • Inventory Program Part 3

    Hi. I'd like to thank all who replied to my Inventory 2 program. Today I am working on Inventory Program Part 3 and need a little help with this also.
    Assignment Description:
    CheckPoint: Inventory Program Part 3
    ?h Resource: Java: How to Program
    ?h Due Date: Day 7 [Individual] forum
    ?h Modify the Inventory Program by creating a subclass of the product class that uses one additional unique feature of the product you chose (for the DVDs subclass, you could use movie title, for example). In the subclass, create a method to calculate the value of the inventory of a product with the same name as the method previously created for the product class. The subclass method should also add a 5% restocking fee to the value of the inventory of that product.
    ?h Modify the output to display this additional feature you have chosen and the restocking fee.
    ?h Post as an attachment in java format.
    I think that I have most of the code correct, however I still have errors withing my code that I have changed around multiple times and still can't figure out how to correct the errors.
    Here is my code for Inventory Program Part 3:
    package inventoryprogram3;
    import java.util.Scanner;
    import java.util.ArrayList;
    public class InventoryProgram3
         * @param args the command line arguments
        public static void main(String[] args)
            Scanner input = new Scanner (System.in);
            DVD[] dvd = new DVD[10];
            dvd[0] = new DVD("We Were Soilders","5","19.99","278");
            dvd[1] = new DVD("Why Did I Get Married","3","15.99","142");
            dvd[2] = new DVD("I Am Legend","9","19.99","456");
            dvd[3] = new DVD("Transformers","4","19.99","336");
            dvd[4] = new DVD("No Country For Old Men","4","16.99","198");
            dvd[5] = new DVD("The Kingdom","6","15.99","243");
            dvd[6] = new DVD("Eagle Eye","2","16.99","681");
            dvd[7] = new DVD("The Day After Tomorrow","4","19.99","713");
            dvd[8] = new DVD("Dead Presidents","3","19.99","493");
            dvd[9] = new DVD("Blood Diamond","7","19.99","356");
            double dvdValue = 0.0;
                for (int counter = 0; > DVD.length ;counter++);
            System.out.printf("\nInventory value is: $%,2f\n",dvdValue);
    class DVD
        protected String dvdTitle;
        protected double dvdPrice;
        protected double dvdStock;
        protected double dvditemNumber;
         public DVD(String title, double price, double stock, double itemNumber)
            this.dvdTitle = title;
            this.dvdPrice = price;
            this.dvdStock = stock;
            this.dvditemNumber = itemNumber;
        DVD(String string, String string0, String string1, String string2) {
            throw new UnsupportedOperationException("Not yet implemented");
         public void setDVDTitle(String title)
            this.dvdTitle = title;
        public String getDVDTitle()
            return dvdTitle;
        public void setDVDPrice(double price)
            this.dvdPrice = price;
        public double getDVDPrice()
            return dvdPrice;
        public void setDVDStock(double stock)
            this.dvdStock = stock;
        public double getDVDStock()
            return dvdStock;
        public void setDVDitemNumber(double itemNumber)
            this.dvditemNumber = itemNumber;
        public double getDVDitemNumber()
            return dvditemNumber;
        public double getValue()
            return this.dvdStock * this.dvdPrice;
        System.out.println();
        *_System.out.println( "DVD Title:" + dvd.getDVDTitle());_*
        *_System.out.println("DVD Price:" + dvd.getDVDPrice());_*
        *_System.out.println("DVD units in stock:" + dvd.getDVDStock());_*    _System.out.println("DVD item number: " + dvd.getDVDitemNumber());_    System.out.printf("The total value of dvd inventory is: $%,.2f\n" ,_*dvdValue*_);
    class MovieGenre extends InventoryProgram3
        private String movieGenre;
        _*public movieGenre(String title, double price, double stock, double itemNumber, String movieGenre)_*
            *_super(dvdTitle, dvdPrice, dvdStock, dvditemNumber, dvdmovieTitle);_*
            *_movieGenre = genre;_    }*
        public void setmovieTitle(String title)
            this.movieGenre = _*genre*_;
        public String getmovieGenre()
            return _*moviegenre*_;
        public double getValue()
            return getValue() * 1.05;
        public double gerestockingFee()
            return getValue() * .05;
        public String toString(Object[] dvdValue)
            return String.format("%s %s\nTotal value of inventory is: %s", dvdValue);
    }I ran the program just to see the error messages:
    Exception in thread "main" java.lang.NoClassDefFoundError: inventoryprogram3/DVD (wrong name: inventoryprogram3/dvd)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at inventoryprogram3.InventoryProgram3.main(InventoryProgram3.java:20)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)
    I really don't understand what's going on here and would appreciate help from anyone who knows and understands Java.
    Thanks in advance.

    You say you "ran" it. I think you mean compiled it? The public class is InventoryProgram3, not DVD.
    If you did mean you tried to run it, then additionally, instead ofjava inventoryprogram3/InventoryProgram3
    Should be
    java inventoryprogram3.InventoryProgram3

  • Socket Programing in J2ME - Confused with Sun Sample Code

    Hai Everybody,
    I have confused with sample code provided by Sun Inc , for the demo of socket programming in J2ME. I found the code in the API specification of J2ME. The code look like :-
    // Create the server listening socket for port 1234
    ServerSocketConnection scn =(ServerSocketConnection) Connector.open("socket://:1234");
    where Connector.open() method return an interface Connection which is the base interface of ServerSocketConnection. I have confused with this line , is it is possible to cast base class object to the derived class object?
    Plese help me in this regards
    Thanks in advance
    Sulfikkar

    There is nothing to be confused about. The Connector factory creates an implementation of one of the extentions of the Connection interface and returns it.
    For a serversocket "socket://<port>" it will return an implementation of the ServerSocketConnection interface. You don't need to know what the implementation looks like. You'll only need to cast the Connection to a ServerSocketConnection .

  • 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

  • Programs part recorded for no apparent reason

    Random programs end up part recorded, no consistency as to which part. Doesn't seem to be linked to other recordings clashing or overrunning, so frustrating when you sit down to watch something and only 5 minutes has been recorded. My old sky box at least used to tell me why i.e. Poor signal. This BT Vision box is driving me crazy, it resets itself randomly too. The only advice I have got from BT is to hard reset the Vision box but this will lose all of my recordings, which isn't acceptable to me. I'm not convinced that this will solve the problem. Any suggestions other than going back to Sky? :-)

    Hi
    I would like to say I have the same symptoms as timtwisters. Is there any feedback from BT if this bug is getting fixed?
    I've just sat down to watch a recorded program to find the last 10 mins not recorded, again! which is soo frustrating. It happens a lot along with the random resetting on its own, usually when recording something which we then lose as well!
    I have double checked all the questions posted above. Loads of capacity available, not specific to any channel, not specific to time of day, not trying to record too many channels, not overlapping, all connections are good etc.
    This seems to be a common thread on forums effecting many people so why do BT still ask for specifics? What further information is required?
    I am fed up of BT telling me to turn it off and wait 10 seconds then turn it back on! This has never worked!
    We move house next month and my wife is begging me to get SKY...BT you have a month.

  • Is "Geography Name Referencing Program" part of upgrade process?

    Hi all,
    We have been upgraded to R12.1.3 and currently into first iteration.
    When querying the old transaction from Transaction workbench window we get, ""The system cannot determine geographical information for this location and cannot derive a tax jurisdiction. Please contact your system Adminstrator" error.
    I have run the "Geography Name Referencing Program" after getting this error. and that error got resolved.
    Kindly Advice,  "Geography Name Referencing Program", is it a part of upgrade process or we have to manually run the program.
    Thanks,
    AtulR

    I have seen the same document and ran the Geographu run referencing program. But my question here is, should we run this program immediately before releasing to Application team which is going to work on Applications
    Have you reviewed the post concurrent programs which are kicked off as part of the upgrade process to verify if the concurrent program was completed successfully or not? The program will be submitted by the upgrade process (as mentioned in the doc that you have already reviewed) and if that's the case the point here is to verify if it completed successfully or not.
    If the program ran successfully and you still hit the same issue then please review the docs in my previous reply. If the docs don't help then please log a SR.
    If the program failed to run then you will need to run it manually.
    If the program was never run by the upgrade then run it manually.
    Thanks,
    Hussein

  • 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.)

  • Inventory Program Part 1

    I am so lost with Part 1 of the Inventory Program for my Java class. I am receiving an error and cannot figure out where it is comming from. The assignment is to:
    Choose a product that lends itself to an inventory (for example, products at your
    workplace, office supplies, music CDs, DVD movies, or software).
    � Create a product class that holds the item number, the name of the product, the number
    of units in stock, and the price of each unit.
    � Create a Java application that displays the product number, the name of the product, the
    number of units in stock, the price of each unit, and the value of the inventory (the
    number of units in stock multiplied by the price of each unit). Pay attention to the good
    programming practices in the text to ensure your source code is readable and well
    documented.
    Here is the code I have so far:
    import java.util.Scanner; // program uses class Scanner
    public class Inventory
         private static void Quit()
    System.out.println("Goodbye");
         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);
         Product Prod = new Product();
         System.out.printf (Prod.toString () );
         System.out.print("\nEnter Prod Name (stop to quit): "); // prompt for name
    Prod.setName(input.nextLine()); // get name
         if(Prod.getName().compareToIgnoreCase("stop") == 0)
    System.out.println("Stop entered, Thank you");
    Quit();
    } //end if
    System.out.print("Enter Prod number for " + Prod.getName() + ": "); // prompt
    Prod.setitemNum(input.nextLine()); // read Prod number from user
    System.out.print("Enter Units on hand: "); // prompt
    Prod.setunits(input.nextDouble()); // read second number from user
         if(Prod.getunits() <= 0)
              System.out.println ("Invalid amount, Units on hand worked must be positive");
              System.out.print("Please enter actual units on hand: ");
              Prod.setunits(input.nextDouble());
         } //end if
         System.out.print("Enter Unit Price: $ "); // prompt
    Prod.setprice(input.nextDouble()); // read third number from user
         if(Prod.getprice() <= 0)
              System.out.println ("Invalid amount, Unit Price must be positive");
              System.out.print("Please enter actual unit price: $ ");
              Prod.setprice(input.nextDouble());
         } //end if
         String fmtStr = "\n%-7s %-10s %12s %12s %12s\n";
         System.out.printf(fmtStr, "Prod #", "Prod Name",
    "Units On Hand", "Unit Cost", "Total Cost");
    for(int i = 0; i<5; i++);
    string Product[] prodArray = new string[5]; *******************
         //Prod[] myArray = new Prod[5]; // allocates memory for 5 strings
    prodArray[0] = "Book"; // initialize first element
    prodArray[1] = "Mag"; // initialize second element
    prodArray[2] = "Hat"; // etc.
    prodArray[3] = "Scarf";
    prodArray[4] = "Rain Gauge";
    System.out.println("Element at index 0: " + prodArray[0]);
    System.out.println("Element at index 1: " + prodArray[1]);
    System.out.println("Element at index 2: " + prodArray[2]);
    System.out.println("Element at index 3: " + prodArray[3]);
    System.out.println("Element at index 4: " + prodArray[4]);
         }//end for
    }//end while
    } //end main
    }// end class Inventory
    // Class Product holds Product information
    class Product
    private String name;
    private String itemNum;
    private double units;
    private double price;
    //default constructor
    public Product()
    name = "";
    itemNum = "";
    units = 0;
         price = 0;
    }//end default constructor
    //Parameterized Constructor
    public Product(String name, String itemNum, double units, double price)
    this.name = name;
    this.itemNum = itemNum;
    this.units = units;
         this.price = price;
    }//end constructor
         public void setName(String name) {
    this.name = name;
         String getName()
              return name;
    public void setitemNum ( String itemNum )
    this.itemNum = itemNum;
    public String getitemNum()
         return itemNum;      }
    public void setunits ( double units )
    this.units = units;
    public double getunits()
              return units;
    public void setprice ( double price )
    this.price = price;
    public double getprice()
         return price;
    public double getvalue()
         return (units * price);
    }//end Class Product
    I am receiving an error on Line 61 ( I have place a few asterisks beside it). The error says inventory.java:61: ';' expected string Product[] prodArray = new string[5]
    Does anyone have an idea what I am doing wrong.

    I reformatted the code and put it inside code tags to retain formatting, anywhere there is a comment, take a pause and compare it to your original to see the differences. Any questions don't hesitate to post them.
    import java.util.Scanner;
    public class Inventory implements Runnable{
        private Product[] prodArray = new Product[5];
        public Inventory() {
            int arraySize = 5;
            prodArray = new Product[arraySize];
            //the for loop did not make sense, since you were loading each object with different information.
            //This is an array of Product Objects
            //anything between two double quotes is a String literal
            //essentially an Object of type String
            //Use your setter methods in the Product class to set the properties of each "new" Product Object.
            //Or use the Parameterized version of your constructor to set the variables inside each "new" object
            //everytime you use the "new" keyword you get a brand spanking new object
            prodArray[0] = new Product();//"Book"; // initialize first element
            //Since you use an empty constructor none of the variable in your Product object have the values you want.
            //Set them after you create your object and assign it to the array.
            prodArray[0].setName("Book");
            //prodArray[0].setprice(0.00);
            //etc...
            prodArray[1] = new Product();//"Mag"; // initialize second element
            prodArray[1].setName("Mag");
            prodArray[2] = new Product();//"Hat"; // etc.
            prodArray[2].setName("Hat");
            prodArray[3] = new Product();//"Scarf";
            prodArray[3].setName("Scarf");
            prodArray[4] = new Product();//"Rain Gauge";
            prodArray[4].setName("Rain Gauge");
            //You never override the toString() method of Product to your output will be the String representation of the
            //Object's reference.
            //I have overidden the toString() method of Product for you using your format, look at it closely.
            System.out.println("Element at index 0: " + prodArray[0]);
            System.out.println("Element at index 1: " + prodArray[1]);
            System.out.println("Element at index 2: " + prodArray[2]);
            System.out.println("Element at index 3: " + prodArray[3]);
            System.out.println("Element at index 4: " + prodArray[4]);
        public void run() {
            showHeader();
            //You never set the name of the Product here and toString doesn't return anything you want to see.
            Scanner input = new Scanner(System.in);
            Product prod = new Product();
            //This show nothing we want to see, try overriding the toString() method in the Product class if you
            //want to see a specific variable of the Product class displayed with the toString() method.
    //        System.out.printf (prod.toString () );
            String inputString;
            int inputInt;
            double inputDouble;
            while( true ) {
                //Don't set invalid data into your Product Object, check to see if it meets your criteria first and then
                //set it.
                System.out.print("\nEnter prod Name (stop to quit): "); // prompt for name
                inputString = input.nextLine();
                if( inputString.compareToIgnoreCase("stop") == 0 ) {
                    System.out.println("Stop entered, Thank you");
                    quit();
                } else {
                    prod.setName(input.nextLine()); // get name
                System.out.print("Enter prod number for " + prod.getName() + ": "); // prompt
                prod.setitemNum(input.nextLine()); // read prod number from user
                System.out.print("Enter Units on hand: "); // prompt
                inputInt = input.nextInt(); // read second number from user
                //to do this check, put your input into a loop, not an if statement.
                //and get an integer from the Scanner not a double,  doubles are not precise and cannot be checked
                //consistently with a loop or if condition
                while ( inputInt <= 0) {
                    System.out.println ("Invalid amount, Units on hand worked must be positive");
                    System.out.print("Please enter actual units on hand: ");
                    inputInt = input.nextInt();
                prod.setunits( inputInt );
                //There are better ways to store currency such as an integer, but there are a lot of conversion you need to do
                // to display them, so just use double for now.
                System.out.print("Enter Unit Price: $ "); // prompt
                inputDouble = input.nextDouble(); // read third number from user
                //while loop here as well and you don't want your products to be $0.00 do you?
                while ( inputDouble < 0.01) {
                    System.out.println ("Invalid amount, Unit Price must be positive");
                    System.out.print("Please enter actual unit price: $ ");
                    prod.setprice(input.nextDouble());
                } //end if
                prod.setprice( inputDouble );
                System.out.println( prod.toString() );
                //You never store the input from the user consider implementing an ArrayList
        private void showHeader() {
            String fmtStr = "\n%-7s%-10s%12s%12s%12s\n";
            System.out.printf(fmtStr, "prod #", "prod Name", "Units On Hand", "Unit Cost", "Total Cost");
        private void quit() {
            System.out.println("Goodbye");
            System.exit (0);
        //Void is not the same as the reseerved word "void"
        //Be sure you watch your capitalizations, all Java reserved words (void, public, static, etc.) are lowercase
        public static void main (String args [] ) {
            //Create an object of type inventory
            Inventory i = new Inventory();
            //start the run method of that object;
            i.run();
    * Class Product holds Product information
    class Product {
        private String name;
        private String itemNum;
        private int units;
        private double price;
         * Constructor
        public Product() {
            //To save space and your sanity you could initialize these variables when they're declared like this.
            // private String name = "";
            name = "";
            //private String item = ""; etc.
            itemNum = "";
            units = 0;
            price = 0;
         * Constructor
         * @param name
         * @param itemNum
         * @param units
         * @param price
        public Product(String name, String itemNum, int units, double price) {
            this.name = name;
            this.itemNum = itemNum;
            this.units = units;
            this.price = price;
        public void setName(String name) {
            this.name = name;
        //This method because it does not have the public keyword is now Package private,
        // it cannot be used outside the current Package.
        String getName() {
            return name;
        public void setitemNum( String itemNum ) {
            this.itemNum = itemNum;
        public String getitemNum(){
            return itemNum;
        //Try to be consistent with your variable and method names, they should start with lower case and each subsequent
        //word should be capitalized like this
        //public void setUnits( double units ) {
        public void setunits( int units ) {
            this.units = units;
        public double getunits() {
            return units;
        public void setprice ( double price ) {
            this.price = price;
        public double getprice() {
            return price;
        public double getvalue() {
            return (units * price);
        public String toString() {
            String fmtStr = "%-7s%-10s%12d%12.2f%12.2f";
            return String.format(fmtStr, itemNum, name, units, price, getvalue() );
    }

Maybe you are looking for

  • Switching to AT&T with family plan -- need multiple iPhone 4's

    We are currently Verizon customers coming to AT&T for the iPhone 4. We want to get three iPhone 4's, along with another regular phone, and put them on a family plan. My son lives 4 hours away, and won't be able to come to the local AT&T store on June

  • ABAP-HR or func HR

    Hi, Which one to go ABAP-HR or func HR??? which has good future???? Thnx in adv Regards, Praveen.

  • Newbie - Boss classes and interfaces

    I'm currently going through Kris Coppieters' "Adobe InDesign CS3/CS4 SDK Programming Getting Started" book and I'm stuck at one of the exercise (11.9) It asks me to create a new boss 'kIDSDKTrainerBoss' which aggregates 2 interfaces 'ISDKTrainerName'

  • Did the double click to open a file or folder go away with the Magic Mouse?

    I see that you can set up the right or left "secondary click" and when you click o a folder or file you get the menu to open, etc. But I really perfer to just double click on a file or folder to open it. I see there is a "Double-Click" option at the

  • Re: Bex query assigment to Role

    Hi All, How to assign a query to user role. We will do that directly in production right? Regards, Anand.