Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-03-2008, 03:44 AM
Member
 
Join Date: Nov 2008
Posts: 2
Rep Power: 0
cserenop51 is on a distinguished road
Default Java Programming in Netbeans
import java.util.Scanner; // program uses class Scanner
public class NewClass5 {

/**
* @param args the command line arguments
*/
// main method begins execution of java application
public static void main( String args[] )
{
System.out.println( "Welcome to the Payroll Program " );


boolean stop = false; // This flag will control whether we exit the loop

// Loop until user types "stop" as the employee name:
while (!stop)
{
// 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 stop to end program: " );
// prompt for and input employee name
String empName = input.nextLine(); // read employee name


if ( empName.equals("stop")) // Check whether user indicated to stop program
{
stop = true;
}
else
{
// User did not indicate to stop, so continue reading info for this iteration:
float hourlyRate; // hourly rate
float hoursWorked; // hours worked
float weeklyPay; // Weekly Pay for employee

System.out.print( "Enter hourly rate: " ); // prompt for hourly rate
hourlyRate = input.nextFloat(); // read hourly rate


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 hourly rate again
}

System.out.print( "Enter hours worked: " ); // prompt for # of hours
hoursWorked = input.nextFloat(); // read # of hours


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 hours worked again
}

// Move on to calculate Weekly Pay.

weeklyPay = (float) hourlyRate * hoursWorked; // multiply the hourly rate by the hours worked

// Display output

System.out.println(); // outputs a blank line
System.out.print( empName ); // display employee name
System.out.printf( "'s weekly pay is: $%,.2f\n", weeklyPay); // display weekly pay
System.out.println(); // outputs a blank line

}
}

// Display ending message:
System.out.println( "Program ended" );
System.out.println(); // outputs a blank line

} // end method main

} // end class Payroll1


Above is my payroll program and works to this point. My next step is

create a class to store and retrieve the information within the program.

I am lost and could use some pointers without actually doing the work.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-03-2008, 04:23 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Are you worrying about that how to create a class in NetBeans? Can you explain your question much clearly.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-03-2008, 06:45 AM
Member
 
Join Date: Nov 2008
Posts: 2
Rep Power: 0
cserenop51 is on a distinguished road
Default
I need 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. then I need to use a constructor to initialize the
employee information, and a method within that class to calculate the weekly pay.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-03-2008, 07:25 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
So where are you stuck with? Are you asking to write this code. First of all you have to make an attempt first. Then ask questions here lol. Start work on step-by-step.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-04-2008, 07:36 PM
Member
 
Join Date: Oct 2008
Location: Aberystwyth
Posts: 55
Rep Power: 0
Nakira is on a distinguished road
Send a message via MSN to Nakira
Default
If you get stuck try breaking your code up into smaller segments. It is an OO Language. lol.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-05-2008, 03:21 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
If you are familiar with OO concepts it's easy to work on. Most important thing is you should have a clever design for the application looking to build
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Programming Tutorial levent Java Tutorials 1 07-04-2008 08:15 AM
Java networking programming (II) Java Tutorial Java Tutorials 0 12-27-2007 06:19 PM
Java networking programming (I) Java Tutorial Java Tutorials 0 12-24-2007 07:21 PM
Java Applet 3D programming ramk Java Applets 0 11-28-2007 10:36 PM
Java Programming JavaForums Java Tutorials 0 07-28-2007 11:10 PM


All times are GMT +2. The time now is 03:46 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org