Welcome to Dream.In.Code
Become a Java Expert!

Join 149,509 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,340 people online right now. Registration is fast and FREE... Join Now!




Java Payroll program for beginning class

 
Reply to this topicStart new topic

Java Payroll program for beginning class, compiles and runs, just not quite right. The loops don't run, it e

bigbluesky
12 Jul, 2007 - 05:49 PM
Post #1

D.I.C Head
**

Joined: 6 Jul, 2007
Posts: 54


My Contributions
CODE
// PayrollPartTwo.java
// payroll that displays an employee name, hours worked, pay rate and total weekly pay.
import java.util.Scanner; // required for keyboard input

public class PayrollPartTwo
{
   // main method begins execution of java application
   public static void main(String args[] )
   {
   // Create a Scanner to obtain input from command window
   Scanner input = new Scanner( System.in );

   String employeeName;               //The name of the employee
   String cleanInputBuffer;           //For cleaning the input buffer
   double hourlyWageInDollars = 0.0;  //The employee wage in dollars
   double hoursWorkedInWeek   = 0.0;  //The Hours worked in the week
   double weeklyWageInDollars = 0.0;  //The employee's pay for the week

   while ( true )

   {
      //Print out a title banner
      System.out.printf( "*********************************" );
      System.out.printf( "Payroll Program Part 2" );
      System.out.printf( "********************************\n\n" );

      //Input the  name of the employee
      System.out.printf( "Please enter the employee's  name ('stop' to quit): " );
      employeeName = input.nextLine(); // Read a line of text

      if ( employeeName.equalsIgnoreCase( "stop" ) )
      {
         break; //Break the main while loop

   }// End if

      // prompt and input hours worked
      System.out.println("Please enter hours worked: " );
      Double hoursWorked = input.nextDouble(); // read a line of text
      System.out.println(); // outputs a blank line

      // prompt and input pay rate
      System.out.println( "Please enter pay rate: " );
      Double payRate = input.nextDouble();// read a line of text
      System.out.println(); // outputs a blank line

      double weeklyPay = hoursWorked * payRate; // multiply numbers

      System.out.printf( "Weekly pay is $%.2f", weeklyPay ); // display product

   } // end method main
} // end class PayrollPartTwo

  //Clean the input buffer
    cleanInputBuffer = input.nextLine(); // Read a line of text to clean the input buffer

} // End while


This post has been edited by alcdotcom: 13 Jul, 2007 - 02:23 AM
User is offlineProfile CardPM
+Quote Post

ravensrock86
RE: Java Payroll Program For Beginning Class
12 Jul, 2007 - 06:12 PM
Post #2

New D.I.C Head
*

Joined: 11 Jul, 2007
Posts: 21


My Contributions
I don't know how to solve your problem; however, your code should be put in code brackets.
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Java Payroll Program For Beginning Class
13 Jul, 2007 - 02:35 AM
Post #3

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,010



Thanked: 7 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
Hello bigbluesky what seems to be the problem here, are there any errors with your code, you think something is missing, please tell us so that we can help.

This post has been edited by PennyBoki: 13 Jul, 2007 - 02:35 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 07:26PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month