473,750 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Another Java question

3 New Member
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.Scann er; // 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.prin tf( "Enter the employee name:" );
name = input.next();

while (!name.equalsIg noreCase("stop" ))
{

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

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

// Hours Worked input
System.out.prin tf( "Enter the number of hours worked:\n" );
hours = input.nextDoubl e( );

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

weeklyPay = rate * hours;

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


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

} // end while loop

} // end method main

} // end class Payroll3[/HTML]
Jun 25 '08 #1
2 1508
r035198x
13,262 MVP
....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 Recognized Expert Expert
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
15377
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 abstracct superclass, with an abstract method such that all subclasses that implement this method make that method static. basically, the abstract class declares an abstract method that should be static for all implementations (for example a factory...
3
2304
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 need to: 1. Click a submit button on an asp page, calling another page that saves the contents of that form to a database and then displays
7
3122
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
56688
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 least, SHOULD make the computer speaker beep. I know that whether the computer speaker actually beeps or not is largely dependent on the OS I'm using. But I'm not so much concerned about that (at this stage). I just want to know if ANSI C++...
2
1796
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 structure */ struct instrument_info {
11
1618
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, subclause 7.3.. Well, I couldn't find the C++ standard definition on the net, so I'm asking here: Why is a thing like assembly covered by the standard at all? According to Victor's response, it seems to be totally compiler dependent what's done with...
3
1611
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 it B) I have a class that contains some UDFs. I want these UDFs to call static methods on class B. Its very important that the static variables in class B is *NEVER* reset. I understand that on each
9
1812
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# Generics (any other difference?i heard that C#'s generic is faster) Java autoboxing == C# autoboxing (java learn from c#?) java enchanced for == C# foreach ( (java learn from c#?) java enumerated type == c# enum (java learn from c#?) java static...
13
2042
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 folks might find to taste. Here's the code - first the 'engine', then some code demonstrating the usage patterns. For me (and maybe for some of you), it promotes readability and some
9
1862
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 CPU-intensive work in another thread, but of course this won't work because of Python's GIL. There's a lot of past discussion on this, and I want to bring it up again because with the work on Python 3000, I think it is worth trying
0
8999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8836
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9338
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6803
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.