Modify the payroll program so that it uses a class to store

Assignment Help Basic Computer Science
Reference no: EM13892638

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.


The application compiles and runs.

The application properly uses a class for employee information.

The application uses a constructor to initialize the employee information and a method within the class to calculate the weekly pay.

The source code is readable and well documented.

The application performs all the required functionality from previous weeks.

 

This is what I already have: 

 

package It215week2;

import java.util.*;
/**
* Monitors employees weekly salary when enter and bonus amount
* Loop feature add
* Program will continue to until user enter "stop" then program will terminate
*
* @author John Doe
*/
public class PayrollSystemProgram {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
try {
// requests the user input the name of the employee, the hourly
// rate, and the number of hours worked.
System.out.print("Enter the name of Employee:");
String employeeName = scanner.nextLine();
while(!employeeName .equals("stop"))
{
System.out.print("Hourly Rate : $");
double hourRate = scanner.nextDouble();
while(hourRate {
System.out.println("Hourly Rate should be a positive value.");
System.out.print("Hourly Rate : $");
hourRate = scanner.nextDouble();
}
System.out.println("Number of hours worked :");
int hoursWorked = scanner.nextInt();
while(hoursWorked {
System.out.println("Hourly Rate should be a positive value.");
System.out.println("Number of hours worked :");
hoursWorked = scanner.nextInt();
}
double weeklyPay = 0, bonusPay = 0;
// calculating weekly pay and bonus pay
if (hoursWorked > 40) {
// if hourly worked is more than 40
// then The bonus amount is the number of hours more than 40
// times the hourly rate
weeklyPay = (double) hourRate * hoursWorked;
bonusPay = (double) (hoursWorked - 40) * hourRate * 0.5;
} else {
weeklyPay = (double) hourRate * hoursWorked;
}
// name of the employee and the correct weekly pay amount in dollar
// format and bonus amount in dollar format
System.out.println("***WEEKLY PAY***");
System.out.println("-----------------");
System.out.println("Employee Name:" + employeeName);
System.out.println("Weekly pay amount :$" + weeklyPay);
if (bonusPay != 0) {
System.out.println("Bonus amount :$" + bonusPay);
}
System.out.print("Enter the name of Employee:");
scanner.nextLine();
employeeName = scanner.nextLine();
}
} catch (Exception e) {
// TODO: handle exception
} finally {
scanner.close();
}
}
}

Reference no: EM13892638

Questions Cloud

Compare characters of troy and rose in august wilsons fences : Compare and contrast the characters of Troy and Rose in August Wilson's Fences. To what extent are each of these characters responsible for their tragedy?
How would such a condition affect your work life : Finally, describe what it might be like to have presbycusis. Include the following points: If you have normal hearing now, how would your ability to converse with others be affected? What activities that you now enjoy would be limited by this conditi..
Describe a specific issue related to health care access : Describe a specific issue related to health care access or policy with respect to a particular ethnic or socioeconomic group.
What does it mean to consecrate a place? : What does it mean to consecrate a place?
Modify the payroll program so that it uses a class to store : 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 w..
How did you frame the decisions you had to make : What biases and past experiences influenced your impressions and decision making? Do you think aspects of your culture or views of a different culture impacted your impressions? How did you frame the decisions you had to make? How did your emotions..
Use the 2s complement : Problem 1  Convert the following decimal numbers into (a) 8-bit, (b) 16-bit, and (c) 32-bit binary numbers. For negative numbers, use the 2's complement. State "overflow" if a number cannot be represented correctly. 1)  45 ten. 2)   -81 ten.  3)-3,0..
What legal implication of these challenges for administraton : Summarize significant findings about this group that inform attitudes and preferences around end-of-life care (e,g., inform consent, life support, advance directives, communication styles, and/or decision making, etc.), and cite your sources of info..
Unadjusted trial balance and information for the accounting : 1.The unadjusted trial balance and information for the accounting adjustments of Noseworthy Investigators follow.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Find an efficient algorithm to determine

Find an efficient algorithm to determine

  How would the distributed 2pl transaction manager

How would the distributed 2PL transaction manager and lock manager algorithms change if a distributed computational model were used?

  Solve equations and show that no solution exists

Solve the following equations for x and y or show that no solution exists. Show your work (in particular, what division must you carry out to solve each case). (i) 5x + 23  6 mod 47

  How do i convert 82 to the 10th power to hex

How do I convert 82 to the 10th power to hex

  Derive taylor polynomials of degree

Derive taylor's polynomials of degree n for: f(x) = (1+x)^(1/2) and f(x) = cos x. Find the approximate value of above functions at x = pi/4 by hand calculator upto two decimal points. Show steps.

  What is best methodology for development of web applications

Introduction (a few paragraphs identifying the specific area your research covers, why it is useful to investigate this area, and an overview of work by other researchers in this area): 20%

  Computer architecture is the combination of software and

computer architecture is the combination of software and hardware that is organized in such a fashion as to deliver the

  Explain what type of ospf link state is advertised

Explain what type of OSPF link state is advertised in each of the following cases: i. A router needs to advertise the existence of another router at the end of a ?point-to-point link. ? ii. A router needs to advertise the existence of two stub networ..

  Logical data-base structure

A report generator is used to. Which of the following is not a logical data-base structure?

  Write a program that reads in an integer

Write a program that reads in an integer and breaks it into a sequence of individual digits in reverse order. For example, the input 16384 is displayed as 4 8 3 6 1 You may assume that the input has no more than five digits and is not negative.

  Satisfying customer needs

There may be times when you are asked to develop a computer system tailored to the customer's needs. An example would be the graphics and publications department of a company. Using this or another example, write an essay describing the customization..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd