Purchase Solution

Developing a Java program to show class design

Not what you're looking for?

Ask Custom Question

Create a non-GUI based Java application that calculates weekly pay for an
employee. The application should display text that requests the user input the name of the employee, the hourly rate, and the number of hours worked for that week. The application should then print out the name of the employee and the weekly pay amount. In the printout, display the dollar symbol ($) to the left of the weekly pay amount and format the weekly pay amount to display currency.

I have attach the pseudocode for it. I have also attach the program that I wrote for it and it will not compile need help on it. Now does the progrma follow suit with the pseudocode or not? In not then how do I go about on doing it?

Purchase this Solution

Solution Summary

In this solution I show how to write a Java program that uses a class to encapsulate the logic about a specific class. I use the example of an Employee class and calculating the employees weekly payrate to illustrate these concepts.

Solution Preview

The initial program was a good start but is was missing a crucial part -- the Employee class. The Employee class is responsible for reading in the values, returning those values, and computing the total weekly pay. Once the employee class is set up to do all of that work the main method in the Payroll class becomes much simpler. Here is what the payroll class looks like:

//Payroll Program (file: Payroll.java)

public class Payroll {

public static void main(String args[])
{
Employee emp = new Employee ();
emp.setName();
while (!emp.getName().equalsIgnoreCase("stop")) {
emp.setPayRate();
emp.setHours();
System.out.printf("n%s's weekly pay is $%.2fn", emp.getName(), emp.getPay());
emp.setName();
}
}
}

Notice that all of the "work" ...

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Javscript Basics

Quiz on basics of javascript programming language.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Basic Networking Questions

This quiz consists of some basic networking questions.