Explore BrainMass

Developing a Java program to show class design

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?


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:

public class Payroll {

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

Notice that all of the "work" ...

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.