473,388 Members | 1,322 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Another Java question

Here we go again...

My next assignment is the following:

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. Make sure the program maintains all the functionality required in previous assignments and your source code is readable and well documented. Use feedback you have received from the instructor to make any needed modifications.

Where do I begin? I have been searching my textbook for hours. I know once I get started I can figure it out, but I am lost.

Here is my payroll application, thus far:


[HTML]// Payroll3.java
// Payroll program that displays the weekly pay of employee.
import java.util.Scanner; // program uses class Scanner // Author: Nicki

public class Payroll3
{

// 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;
double rate;
double hours;
double weeklyPay;

// prompt for and input employee name
System.out.printf( "Enter the employee name:" );
name = input.next();

while (!name.equalsIgnoreCase("stop"))
{

// Hourly Rate input
System.out.printf( "Enter the employee's hourly rate in dollars:\n" );
rate = input.nextDouble( );

while ( rate < 0 )
{
System.out.printf( "Please enter a positive value:" );
rate = input.nextDouble( );
} // end while loop (pay rate)

// Hours Worked input
System.out.printf( "Enter the number of hours worked:\n" );
hours = input.nextDouble( );

while ( hours < 0 )
{
System.out.printf( "Please enter a positive value:" );
hours = input.nextDouble( );
} // end while loop (hours worked)

weeklyPay = rate * hours;

// Output the result
System.out.print(name + " earned ");
System.out.printf( " $%.2f", weeklyPay );


// prompt for and input employee name
System.out.printf( "Enter the employee name:" );
name = input.next( );

} // end while loop

} // end method main

} // end class Payroll3[/HTML]
Jun 25 '08 #1
2 1491
r035198x
13,262 8TB
....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. ..
Your starting point is creating the Employee class.
Jun 25 '08 #2
RedSon
5,000 Expert 4TB
Next time please provide a better title for your question instead of "Another Java Question"
Jun 26 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Murat Tasan | last post by:
so here is another general question about java... why can't you declare an abstract static method. i can envision the case (indeed i have experienced the case) where one would want an...
3
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
7
by: jesse | last post by:
In java, one constructor can call another constructor through this(...) for instance class foo { public: foo(int k) { this(k,false)}; foo(int k, boolean m){...}; }
19
by: Anon Email | last post by:
Hi everyone, Let's see, now. This question is about the capabilities of ANSI C++. I want to write and compile code in ANSI C++ that, when compiled, will make the computer speaker beep; or, at...
2
by: andy.dreistadt | last post by:
Hi all, I came across another problem that is probably pretty easy but, again, due to my rusty-ness with C, I'm a little stumped. I have a struct that looks like this: /* Instrument Data...
11
by: Johannes Bauer | last post by:
Hi group, inspired by the other inline assembly thread a question popped up in my mind... Victor Bazarov mentioned in his response that the asm() clause was covered by the C++ standard,...
3
by: Jae | last post by:
Hello, here's what I want to do but I'm not sure if it will work because Im not sure how DB2 works with the JVM. Heres my setup: DB2---->UDF Class (lets call it A)----->Static Class (Lets call...
9
by: babylon | last post by:
i just read this (http://java.sun.com/developer/technicalArticles/releases/j2se15/) am I correcting on these concepts? Java Metadata == C# Attribute (java learn from c#?) Java Generics == C#...
13
by: aum | last post by:
Hi, I'm a Python programmer, just starting to get into javascript. On reading some of the js guides, and not liking any of the OO usage patterns I saw, I've cooked up something which python...
9
by: cgwalters | last post by:
Hi, I've recently been working on an application which does quite a bit of searching through large data structures and string matching, and I was thinking that it would help to put some of this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.