Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / October 2006

Tip: Looking for answers? Try searching our database.

i cant seem to figure something simple out

Thread view: 
porky008 - 18 Oct 2006 21:00 GMT
i need to modify the following 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. for some
reason i cant seem to grasp this simple  task. can some plese help me
out on this? thanks

import java.util.Scanner;

public class Payroll2

{

  public static void main(String[] args)
  {

     // Variable Declaration
     double payrate;    // Hourly Rate of employee
     double hours;      // Hours Worked by employee
     double grosspay;   // Weekly Pay for employee
     Scanner keyboard;

     Scanner input = new Scanner( System.in );

     // Get employee's name
     System.out.printf( "Enter the employee's name(Enter stop when
finished):");

     String name = input.next();
      while(!name.equals("stop"))

     { // Start of name while loop

     // Get hourly rate of employee
     System.out.printf( "Enter the employee's hourly pay rate: " );
      payrate = input.nextDouble();
      while (payrate<=0)
      { // start payrate while loop
              System.out.printf("\nPayrate must be positive, try again:");
              payrate = input.nextDouble();
      } // end of payrate while loop

     // Get hours worked for the pay period
     System.out.printf( "Enter the number of hours worked in this pay
period: ");
      hours = input.nextDouble();
      while ( hours <= 0 )
          { // start the hours while loop
              System.out.printf( "\nSorry you need to enter a positive
number for the Hours:");
              hours = input.nextDouble();
          } // end hours while loop

     // This calculates the gross pay.
     grosspay = hours * payrate;

     // Display results and reshows what you have entered
     System.out.printf( "\nemployee: %s", name );
     System.out.printf( "\nhourly rate: $%.2f", payrate );
     System.out.printf( "\nhours worked: $%.2f", hours );
     System.out.printf( "\nweekly paycheck: $%.2f\n",grosspay);

     System.out.printf( "\n\n\nEnter another employee's name (Enter
stop when finished):");
        name = input.next();
   
     }// End of name while loop
       
   }
     
}
Andrew Thompson - 19 Oct 2006 00:37 GMT
> i

Please find your 'shift' key and apply it once at
the start of each sentence.

>...need to modify the following 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. for some
> reason i cant seem to grasp this simple  task.

I guess that is because you have done none of
the reading, nor preliminary exercises, that your
teacher suggested thus far.

>..can some plese help me out on this?

But in case I am wrong, and you just need a
push in the right direction.  The best help I
can offer at this stage is..
<http://home.earthlink.net/~patricia_shanahan/beginner.html>

Andrew T.
CodeFish - 26 Oct 2006 09:30 GMT
> <http://home.earthlink.net/~patricia_shanahan/beginner.html>
>
> Andrew T.

I could not get the links to the FAQ on this page (500-Internal Server
error). I think I found a few more like this when browsing your site a
few days ago. Hope it's nothing too serious. Proky probably won't
pick-up on it, but there are some of us who appreciate posts that don't
give all the answers.
Andrew Thompson - 26 Oct 2006 10:19 GMT
> > <http://home.earthlink.net/~patricia_shanahan/beginner.html>
...
> I could not get the links to the FAQ on this page (500-Internal Server
> error).

The majority of PhySci was spfritzed* some time ago.
A miniscule number of pages have been resurrected,
and some of the pure HTML pages are still accessible,
but until/unless I find a CMS** that provides simple &
valid templates, the rest might remain off-line.    :-(

* That was a term I invented on the spot.

** There are only have a few free content management
systems on offer at my current host - and I am not
especially impressed with the little I know of any
of them.

>..I think I found a few more like this when browsing your site a
> few days ago. Hope it's nothing too serious. ...
>..there are some of us who appreciate posts that don't
> give all the answers.

Yes, I understand where you're coming from..

Andrew T.
porky008 - 26 Oct 2006 17:48 GMT
> > > <http://home.earthlink.net/~patricia_shanahan/beginner.html>
> ...
[quoted text clipped - 22 lines]
>
> Andrew T.

Sure like some I do like to get the code back but getting a link to a
page that might help or anything that helps is nice. I read all that I
can find but this stuff still makes little to no sense to me. After I
have look everywhere that I can think of then I post to here in hopes
of getting something useful, regardless of the form it may come in.
Oliver Wong - 27 Oct 2006 18:08 GMT
> Sure like some I do like to get the code back but getting a link to a
> page that might help or anything that helps is nice. I read all that I
> can find but this stuff still makes little to no sense to me. After I
> have look everywhere that I can think of then I post to here in hopes
> of getting something useful, regardless of the form it may come in.

   It helps if you ask a specific question. Or else we'll have to ask YOU
questions to get information we're missing and that we need to help you, and
a lot of us are too lazy to go through all that effort.

   Are you still stuck? If so, did you read the the page at the link Andrew
posted? If so, what step are you stuck at?

   - Oliver
porky008 - 27 Oct 2006 22:27 GMT
i have gotten this one to wrok thanks to help i got from here now i am
working on one using arrays which for now is going ok i just need to
figure out how to let the user enter the info but i still have a few
days befor i HAVE to start asking fo rhelp on it

> > Sure like some I do like to get the code back but getting a link to a
> > page that might help or anything that helps is nice. I read all that I
[quoted text clipped - 10 lines]
>
>     - Oliver
Oliver Wong - 27 Oct 2006 22:40 GMT
> i have gotten this one to wrok thanks to help i got from here now i am
> working on one using arrays which for now is going ok i just need to
> figure out how to let the user enter the info but i still have a few
> days befor i HAVE to start asking fo rhelp on it

   Okay, but don't wait until the last minute. Sometimes you have to wait
48 hours, or even longer, before someone replies to your message.

   You might also want to read up on usenet etiquette (see
http://kb.iu.edu/data/abcy.html), to increase the chance that someone
replies to your question. You've been top-posting a lot, for example.
Something that's generally disapproved of.

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.