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

  Various variables to store various information

While doing programming in any programming language, you need to use various variables to store various information.Describe those variable in details.

  The organizational strategy

Where would database processing systems and spreadsheets fit into the organizational strategy

  Compare time complexity of convolution with kernel

Compare the time complexity of convolution with a n x n kernel when using: direct convolution with the 2-D mask, and separable kernel.

  Programming tasks use any high-level programming

Programming Tasks Use any high-level programming language you wish for the following programming exercises. Do not call built-in library functions that accomplish these tasks automatically. (Examples are sprintf and sscanf from the Standard C librar..

  Identify three error types you will look for

Explain your approach for verifying that the spreadsheet does not contain errors. Identify three error types you will look for. Identify 3R's to look for, and why is this important? Describe the elements of a professionally formatted datasheet.

  Explain how cloud-based data storage works

Explain how cloud-based data storage works. What factors you consider when selecting a vendor for a cloud-based storage solution for your company

  Design class diagram for the create registry

Design Class Diagram for the Create Registry and design one sequence diagram for each communication diagram.

  These processes compete to use the computers

a modern personal computer or workstation executes many simultaneous processes. these processes compete to use the

  Why is the same not true if is replaced

Explain why replacing the extracellular with choline has little effect on the resting potential of an axon. Calculate the new resting potential with 90% of the extracellular removed. Why is the same not true if is replaced? (Assume the conductance..

  Write a sql query to display customer id

Use joining technique (WHERE commands is preferred[1]) to write a SQL query to display customer ID, customer name, and customer address for all the customers who are doing business with PVFC in the territory of Southwest.

  Produce an identical product

There are two firms in a market that produce an identical product. Each firm has either one or zero units to sell. The probability of having a unit to sell is q and the probability of having no units to sell is 1-q. There is a single consumer ..

  Computer ethics the deep web or green computing

Choise a technology topic to research on the internet, such as cloud computing. Web 2.0, computer ethics, the deep web, or green computing. Using the techniques you learned in this lesson, search for web related to your topic.

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