I am having a little trouble with classes

I can not figure out what is wrong or missing from this code because I keep getting "declare in file" error code
this is the simple code
import java.util.Scanner; //program uses class Scanner
import java.text.NumberFormat;//used to format currency
import java.util.Locale;
public class Employee
public Employee();
//main method begins execution of Java application
//create Scanner to obtain input from command window
Scanner input=new Scanner (System.in);
//varibles declared
String Emp_name;//Stores employee name
double Hours_worked;///Stores hours worked
double PayRate;//Stores PayRate
System.out.print("Enter Employee;s name:");//prompt
Emp_name=input.nextLine();//read employee's name entered
System.out.print("Enter the pay rate of the Employee:");//prompt
PayRate=input.nextDouble();//read the payrate of employee
System.out.print("Enter the Employee's Hours worked:");//prompt
Hours_worked=input.nextDouble();//read hourlyrate of pay entered by user
NumberFormat nf=NumberFormat.getCurrencyInstance(Locale.US);
System.out.printIn("Employee" + Emp_name);//display employee_Name
System.out.printf("Employee's Pay: $" +nf.format(Hours_worked*PayRate));//display GPA
}

masterbuild,
Firstly, post your code between code tags.
[code]... your code goes here ...[/code]
so it looks like thisdouble check it using preview before you commit the post.
Now, Please don't be offended, That's not a bad first try, but it's just all wrong, which is part of the learning process.
Here's a list the problems I can see with that code, and what to do about them... if you address these problems you should end up with a working program.
Number 1
public class Employee
public Employee();
//main method begins execution of Java application
{As The Pair of Condiments and The Sick Brainiac have already stated... lose the semicolon!... it should look like this...
public class Employee
  public Employee() {
Number 2
//main method begins execution of Java application
What main method? I don't see any main method... Where's your main method? It should look like this
  public void main(String[] args) {
    Scanner input = new Scanner(System.in);
    System.out.print("employee's name : ");
    String name = input.nextLine();
    System.out.print("hourly rate : ");
    double hourlyRate = input.nextDouble();
    System.out.print("hours worked : ");
    double hoursWorked = input.nextDouble();
    System.out.printf("%s's gross pay is $%s\n", name, NUMBER_FORMATTER.format(hoursWorked*hourlyRate));
  }* The convention is to use camelCase (hump in the middle) for variable names, and CapitalCase for class names. See http://java.sun.com/docs/codeconv/
Number 3
The numberFormatter would best be declared as a class attribute, so you can reuse whenever you print a currency amount... as in...
public class Employee
  private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getCurrencyInstance(Locale.US);
  public Employee() {
    ....Also... these three comments worry me a bit...
// Stores employee name
// Stores hours worked
// Stores PayRate
None of these values are being "stored". These three values are local variables, which exist only while the method (actually block) in which they are declared is executing... after that they are "forgotten". To a programmer the word "store" implies that the values are being persisted in a file, or database... that is the values are being stored in any fashion for reuse by a subsequent execution of this program, or indeed another program. I think it's just that you don't know the lingo yet, but I just wanted to be sure that you know that these values will be forgotten as soon as the main method is finished.
Cheers. Keith.

Similar Messages

  • Having a little trouble with the "export" dialog box

    Hi all,
    When I get to the export dialog box, I'm not able to type directly in the "Custom Name" space.  I have to click around and fiddle with some of the drop-down menus (and then get back to the "name format" that I like) and only then can I triple-click or backspace on the former name and input a new name in the "Custom Name" blank.
    Also, the "Export Versions" tab is highlighted, but hitting the "return" key doesn't make the export happen.  I have to mouse up to that button and click it that way.
    Is anyone else having any trouble with inputting information on the export page?  And ideas?
    Thanks as always.

    Yes, the name format is Custom Name with Index.  But when I click in the field, I can't edit it.
    Mark,
    For me, this preset is working well. Have you checked, if the preset for  "Custom Name with Index" correct?  You can verify it, by setting the "File Naming" format to "Edit". The preset should look like this:
    I'd try to edit the preset, save it, and edit it back, to create a new preset file.
    If that does not help, remove the user Aperture User Preferences, as described in this document:  Aperture 3: Troubleshooting Basics
    And as I said, hitting "return" doesn't start the export.
    That also your "Export" button is not responding to return, even if it is highlighted in blue, is a sign, that your preferences file might have a problem.
    Regards
    Léonie

  • Still having a little trouble with template

    Hi,
    Can anyone please take a look at the following page and tell
    me what's going on with my faux columns?
    BPI
    Test Site - Activities Page. Since my pages are varying heights
    I eliminated the "page height" command for my center content div,
    using the "clearer" convention in my style sheet. Seems to work
    great in IE but I'm having a problem with FF and Netscape. I'm
    thinking that the Code isn't quite right somewhere in my template
    page (pasted below) but I'm not sure. Any help appreciated. Thanks

    It works to clear the floats BEFORE the containing div is
    closed - that's
    what forces the container to re-contain all of the stuff
    that's floated.
    Your code was clearing the float AFTER closing the container,
    and that
    doesn't do the job.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "webmom24" <[email protected]> wrote in
    message
    news:e86m4j$es$[email protected]..
    > Thanks Gary. That worked. Of course, I'm curious now why
    the code works
    > fine as
    > is on the home page (with it in the other position). Can
    you tell me what
    > this
    > little bit of code does? I'd like to try and understand
    it... right now
    > it's a
    > mystery to me why it works LOL. Thanks again.
    >
    > Maureen
    >

  • Having a little trouble with GridBagLayout.

    OK. What i basically need to do is have JPanel (GridBagLayout) with a JTextField covering cells from 0-3, then have a JButton in cell 4. This is all on one line.
    Because i am only adding two components to the JPanel, and asking it to act as though it had 5, i guess it doesn't like it. I think it should work like that but what can i do :) ...
    Help would be appreciated, thanks.

    GridBagLayout doesn't size the components in it based on the number of cells the component occupies (except relative to other rows/columns which you don't have). It sizes on the preferred size of the component along with the fill and weight of the GridBagConstraints for each component.
    I usually set preferred size of the textfield to 4 times the button, set the weightx of both components to 1.0 and then set the fill for both components to HORIZONTAL.
    You could also set the preferred sizes the same, the weightx of the textfield to 4.0, the weightx of the button to 1.0 and the fill for both to HORIZONTAL.

  • Hi! I'm just having a little trouble when it comes to battery charging of my iPhone 5 with its new iOS 7! It doesn't indicates that the battery is fully charge unlike the old version of iOS! They said it should be pulsating but it's not

    Hi! I'm just having a little trouble when it comes to battery charging of my iPhone 5 with its new iOS 7! It doesn't indicates that the battery is fully charge unlike the old version of iOS! I already read some reviews and discussion about this. They said that the lightning bolt should pulsate when charging but it's not!

    Thanks for the replies. It took a while not hearing anything so thought I was alone. I have done many of the suggestions already. The key here is that it occurs on both phones with apps, and phones still packaged in a box.
    A Genius Bar supervisor also checked his Verizon data usage log and found the same 6 hour incremental use. Suprisingly, he did not express much intrigue over that. Maybe he did, but did not show it.
    I think the 6 hour incremental usage is the main issue here. I spoke with Verizon (again) and they confirmed that all they do is log exactly when the phone connected to the tower and used data. The time it records is when the usage started. I also found out that the time recorded is GMT.
    What is using data, unsolicited, every 6 hours?
    Why does it change?
    Why does it only happen on the iPhone 5 series and not the 4?
    Since no one from Apple seems to be chiming in on this, and I have not received the promised calls from Apple tech support that the Genius Bar staff said I was suppose to receive, it is starting to feel like something is being swept under the rug.
    I woke up the other day with another thought ... What application would use such large amounts of data? Well ... music, video, sound and pictures of course. Well ... what would someone set automatically that is of any use to them? hmmm ... video, pictures, sound. Is the iPhone 5 succeptible to snooping? Can an app be buried in the IOS that automatically turns on video and sound recording, and send it somewhere ... every 6 hours? Chilling. I noted that the smallest data usage is during the night when nothing is going on, then it peaks during the day. The Genius Bar tech and I looked at each other when I drew this sine wave graph on the log print outs during an appointment ...

  • I just uploaded the latest IPad software to my IPad and am now having loads of trouble with the device recognizing "online buttons", that is, links, etc.

    I just uploaded the latest IPad software to my IPad and am now having loads of trouble with the device recognizing "online buttons", that is, links, etc.  what can I do?

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:
    iOS: How to back up
    - Restore to factory settings/new iOS device.
    -  Make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar

  • I am having alot of trouble with svg files is there some one well versed with adobe svg file

    I am having alot of trouble with svg files is there some one well versed with adobe svg file

    Clearing out cookies while in gmail helped me to get all functionality back. One of those sites must have messed with gmail. Thanks so much for the help.

  • Why am I having so much trouble with my iPad air 2 reading and remembering my fingerprints?

    Why am I having so much trouble with my iPad air 2 reading and remembering my fingerprints? Even if I enter the same finger 5 times, it only works once or twice.

    Try this -> http://m.facebook.com
    which is the mobile optimized page of FaceBook.

  • I  have been having nothing but trouble with OS 10.6.8.  Many of my appliatins will not work..  HOw can I revert back to a previous version of OS x?

    I  have been having nothing but trouble with OS 10.6.8.  Many of my applications will not work..  HOw can I revert back to a previous version of OS x?

    Before you revert anything try this:
    Reinstall OS X without erasing the drive
    1. Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Reinstall Snow Leopard
    If the drive is OK then quit DU and return to the installer.  Proceed with reinstalling OS X.  Note that the Snow Leopard installer will not erase your drive or disturb your files.  After installing a fresh copy of OS X the installer will move your Home folder, third-party applications, support items, and network preferences into the newly installed system.
    Download and install Mac OS X 10.6.8 Update Combo v1.1.
    Next time don't post something like "nothing but trouble." Tell us exactly what the trouble is and provide any additional information such as error messages.

  • My iPod touch is having a little issue with the volume. When I plug in my headphones the volume works fine. When there aren't any headphones plugged in, no sound comes out from my iPod. When I go to turn up the volume, it still says headphones. Any tips?

    My iPod touch is having a little issue with the volume. When I plug in my headphones the volume works fine. When there aren't any headphones plugged in, no sound comes out from my iPod. When I go to turn up the volume, it still says headphones. I tried restarting it a few times, nothing worked. I looked up many tutorials, and still nothing did the trick. Any tips?

    - Try cleaning out/blowing out the headphone jack. Try inserting/removing the plug a dozen times or so.
    Try the following to rule out a software problem
    - Reset the iPod. Nothing will be lost
    Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup
    - Restore to factory settings/new iPod.
    - Make an appointment at the Genius Bar of an Apple store. Seems you have a bad headphone jack.
    Apple Retail Store - Genius Bar
    Apple will exchange your iPod for a refurbished one for this price. They do not fix yours.
    Apple - iPod Repair price                  
    A third-party place like the following will replace the jack for less. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
    Replace the jack yourself
    iPod Touch Repair – iFixit

  • Ever since I update my iPhone to ios 7 I been having so much trouble with it. I lost my contacts, my notes, I set a ringtone and it change it... What should I do?. I love iPhone but this is making me angry.

    Ever since I update my iPhone to ios 7 I been having so much trouble with it. I lost all my contacts all the time, my notes, I set a ringtone and it change it... What should I do?. I love iPhone but this is making me angry. :(

    Basic troubelshooting steps have not changed in iOS 7.  Restart, reset, restore from backup, restore as new.

  • CanI downgrade back to the previous, non4.0 version? I am having too much trouble with 4.0

    How can I downgrade back to the previous, non4.0 version? I am having too much trouble with 4.0, such as:
    1) cannot save multible tabs in bookmarks
    2) 4.0 is not faster, perhaps even slower
    3) crashes often, especially when I scroll through my emails in Yahoo email.
    4) Moved the "stop loading" and "refresh" buttons to the right, ala MS Internet Explorer. I liked your old location better.
    Thank you,
    Gary Bright

    try this link http://www.mozilla.com/en-US/firefox/all-older.html
    Uninstall 4.0. DO NOT CHECK "Remove my Firefox personal data"

  • Trouble with class

    I am unable to figure out what I am having trouble with this, here is the code
    public class Tools3
        protected long item_number;
        protected String product_name;
        protected long units_in_stock;
        protected double price_of_each_unit;
        protected static double total_price_of_inventory;
    public Tools3( long pitem_number, String pproduct_name, long punits_in_stock, double pprice_of_each_unit)
       item_number = pitem_number;
       product_name = pproduct_name;
       units_in_stock = punits_in_stock;
       price_of_each_unit = pprice_of_each_unit;
       total_price_of_inventory = punits_in_stock * pprice_of_each_unit;
    // Overloaded constructor for empty balance
    public Tools3()
       item_number = 0;
    public void set_item_number( long pitem_number )
       item_number = pitem_number;
    public void set_product_name( String pproduct_name )
       product_name = pproduct_name.toString();
    public void set_units_in_stock( long punits_in_stock )
       units_in_stock = punits_in_stock;
    public void set_price_of_each_unit( double pprice_of_each_unit )
       price_of_each_unit = pprice_of_each_unit;
    public long get_item_number()
       return item_number;
    public String get_product_name()
       return product_name;
    public long get_units_in_stock()
       return units_in_stock;
    public double get_price_of_each_unit()
       return price_of_each_unit;
    public double calculate_total_price()
       return units_in_stock * price_of_each_unit;
    public double calculate_total_price_of_inventory(Tools3[] mytools)
       double rettotal = 0;
       for (int i = 0; i < mytools.length; i++)
        rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_each_unit());
       return rettotal;
      public void sort_by_names(Tools3[] mytools)
      int a,b;
      int sortTheStrings = mytools.length - 1;
      String tempproduct_name;
      long tempitem_number;
      long tempunits_in_stock;
      double tempprice_of_each_unit;
        //need to implement a bubble sort here
        for (a = 0; a < sortTheStrings; ++a)
      for (b = 0; b < sortTheStrings; ++b)
      if(mytools.product_name.compareTo(mytools[b + 1].product_name) >0)
        //move name
        tempproduct_name = mytools.product_name;
        mytools.product_name = mytools[b+1].product_name;
        mytools[b+1].product_name = tempproduct_name;
        //move item_number
        tempitem_number = mytools.item_number;
        mytools.item_number = mytools[b+1].item_number;
        mytools[b+1].item_number = tempitem_number;
        //move units_in_stock
        tempunits_in_stock = mytools.units_in_stock;
        mytools.units_in_stock = mytools[b+1].units_in_stock;
        mytools[b+1].units_in_stock = tempunits_in_stock;
        //move price_of_each_unit
        tempprice_of_each_unit = mytools.price_of_each_unit;
        mytools.price_of_each_unit = mytools[b+1].price_of_each_unit;
        mytools[b+1].price_of_each_unit = tempprice_of_each_unit;
    //end of tools3.java class

    Results from javac
    C:\Java>javac Tools3.java
    Tools3.java:77: cannot find symbol
    symbol  : method get_units_in_stock()
    location: class Tools3[]
        rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_e
    ach_unit());
                                      ^
    Tools3.java:77: cannot find symbol
    symbol  : method get_price_of_each_unit()
    location: class Tools3[]
        rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_e
    ach_unit());
                                                                     ^
    Tools3.java:94: cannot find symbol
    symbol  : variable product_name
    location: class Tools3[]
      if(mytools.product_name.compareTo(mytools[b + 1].product_name) >0)
                ^
    Tools3.java:97: cannot find symbol
    symbol  : variable product_name
    location: class Tools3[]
        tempproduct_name = mytools.product_name;
                                  ^
    Tools3.java:98: cannot find symbol
    symbol  : variable product_name
    location: class Tools3[]
        mytools.product_name = mytools[b+1].product_name;
               ^
    Tools3.java:101: cannot find symbol
    symbol  : variable item_number
    location: class Tools3[]
        tempitem_number = mytools.item_number;
                                 ^
    Tools3.java:102: cannot find symbol
    symbol  : variable item_number
    location: class Tools3[]
        mytools.item_number = mytools[b+1].item_number;
               ^
    Tools3.java:105: cannot find symbol
    symbol  : variable units_in_stock
    location: class Tools3[]
        tempunits_in_stock = mytools.units_in_stock;
                                    ^
    Tools3.java:106: cannot find symbol
    symbol  : variable units_in_stock
    location: class Tools3[]
        mytools.units_in_stock = mytools[b+1].units_in_stock;
               ^
    Tools3.java:109: cannot find symbol
    symbol  : variable price_of_each_unit
    location: class Tools3[]
        tempprice_of_each_unit = mytools.price_of_each_unit;
                                        ^
    Tools3.java:110: cannot find symbol
    symbol  : variable price_of_each_unit
    location: class Tools3[]
        mytools.price_of_each_unit = mytools[b+1].price_of_each_unit;
               ^
    11 errors

  • Having alot of trouble with a query

    Hey, I'm having trouble with a query for an assignment. The questions states
    Find the name of the highest earning employee in each location, excluding managers, salespeople and the president
    The problem I'm having is that my query returns the highest earning employee from each location perfectly, but one of those returned is a salesperson, so the next highest earning person in that location should be returned.
    We are also not allowed to create a temporary table
    Here's my code so far
    select
    e.first_name,
    e.last_name,
    e.salary,
    l.regional_group
    from employee e
    inner join department d
    on d.department_id = e.department_id
    inner join location l
    on l.location_id = d.location_id
    where e.salary = (select max(e2.salary) from employee e2
    inner join department d2
    on d2.department_id = e2.department_id
    inner join location l2
    on l2.location_id = d2.location_id
    where l2.location_id = l.location_id
    and e.job_id !=672;
    the job_id refers to what job title they have
    and here's the schema below
    Schema
    Any help you could give me on this would be fantastic as I have been pulling my hair out over this for the last day.
    Edited by: 837562 on 17-Feb-2011 02:14

    Maybe you can try the below:
    with job_location as
    select 1 location_id, 'loc1' regional_group from dual
    union
    select 2 location_id, 'loc2' regional_group from dual
    department as
    select 1 department_id, 'dept1' dept_name, 1 location_id from dual
    union
    select 2 department_id, 'dept2' dept_name, 2 location_id from dual
    job_FUNCTION as
    select 1 job_id, 'MANAGER' job_function from dual
    UNION
    select 2 job_id, 'SALES' job_function from dual
    UNION
    select 3 job_id, 'PRESIDENT' job_function from dual
    UNION
    select 4 job_id, 'REST_1' job_function from dual
    UNION
    select 5 job_id, 'REST_2' job_function from dual
    employee as
    select 1 employee_id, 'a' last_name, 100 salary, 1 department_id, 4 JOB_ID from dual union
    select 2 employee_id, 'b' last_name, 200 salary,1, 5 from dual union
    select 3 employee_id, 'c' last_name, 300 salary,1, 2 from dual union
    select 4 employee_id, 'd' last_name, 400 salary,1, 2 from dual union
    select 5 employee_id, 'e' last_name, 500 salary,2, 3 from dual union
    select 6 employee_id, 'f' last_name, 600 salary,2, 3 from dual union
    select 7 employee_id, 'g' last_name, 700 salary,2, 4 from dual union
    select 8 employee_id, 'h' last_name, 800 salary,2, 4 from dual
    select
    regional_group, employee_id, max_salary
    from
    select e.regional_group, b.department_id, employee_id, salary, max(b.salary) over (partition by b.department_id order by b.department_id) max_salary
    from
    employee b,
    job_function c,
    department d,
    job_location e
    where
    b.job_id = c.job_id and
    b.department_id = d.department_id and
    e.location_id = d.location_id and
    c.job_id not in (1,2,3) 
    ) where salary = max_salary;
    "REGIONAL_GROUP"     "EMPLOYEE_ID"     "MAX_SALARY"
    "loc1"     "2"     "200"
    "loc2"     "8"     "800"

  • I'm having so much trouble with my I.D account

    I'm having sume trouble with my account I.D plz help.

    If you say what the problems are then somebody on these forums might be able to help.

Maybe you are looking for

  • One Computer, Multiple Users, Multiple iTunes Libraries

    Hello My family shares a single Mac via Fast User Switching. We all have separate iTunes libraries. I had some difficulty getting TV to be able to use all of the iTunes libraries as alternate sources for streaming music. I'm posting this here as I'v

  • Error with PSAPI.DLL during installation of SOA Suite

    Hi, During installation, when progress bar is 99%, the installer send the message "javaw.exe: The procedure entry point GetProcessImageFileNameW could not be located in the dynamic link library PSAPI.dll". The installation continues and it seems that

  • VOFM output control routine for VT01N

    I need to know what the temporary strucutre or internal table is that SAP uses for deliveries.  The values eventually get stroed in table VTTP.  But when using VT01N they are not there of course until it is actually saved to the DB.  The output contr

  • ERROR = plugin: illegal host in ~designbaseurl

    All, We have been stumped by the following.  We are running NW 7.00 on AIX 5.3 and Oracle database 10g.  This error occurs randomly.  It occured when we went from kernel 7.00 patch 102 to kernel 7.0 patch 157.  That was the only thing that changed ot

  • Clear waveform chart history if dynamic 1D data is used

    I am new to Labview and am using a Waveform Chart.  To clear this I need to supply an empty array.  I have done this with scalar inputs, but in this present case, the input to the chart is a bundle of 1-D array of dynamic data. I cannot figure out ho