Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//This program will process payroll. It will allow you to //process payroll for as many employees as you wish. You need to //enter employee's Name

//This program will process payroll. It will allow you to //process payroll for as many employees as you wish. You need to //enter employee's Name and Salary. Then if Salary>=60000.00

//calculate Federal Tax to be 20% and State Tax to be 10%.

//Otherwise, Federal Tax will be 15% and State Tax to be 5%.

// Then subtract taxes from salary and calculate net pay.

// The program then should display, employee name, salary, //federal tax, state tax and net pay.

// Run the program 2 times, //first enter a salary greater than or equal to 60,000.00, then enter a salary //that is less than 60,000.

import java.util.Scanner;// Needed for the Scanner class /**This program demonstrates a user controlled loop and caclutes payroll. */ // Name of the class should be your name

// for example publicclass AndyGarsiaHm1 publicclass YourNameHm1 { publicstaticvoid main(String[] args) {

// Variables have been declared String Name; double Salary; double Federal; double State; double totalTax; double Net; char repeat; // To hold 'y' or 'n' String input; // to hold input System.out.println("This program calculates Payroll"); // Create a Scanner object for keyboard input. Scanner keyboard =new Scanner(System.in); // process as many payroll as the user wants. System.out.println("Would you like to Process Payroll

System ?"); System.out.print("Enter Y for yes or N for no: "); input = keyboard.nextLine(); // Read a line. repeat = input.charAt(0); // Get the first char. while (repeat =='Y' || repeat =='y') { // Get the data for Name and Salary System.out.print("Enter Employee Name: ");

// Code Method to Get employee name from Keyboard System.out.print("Enter Employee's Salry?"); // Code Method to Get employee salary // Calculate Taxes if (Salary>=60000.00) { //Statement to Calculate Federal tax that is 20% // Statement to Calculate State tax that is 10% } else { //Statement to Calculate Federal tax that is 15% // Statement to Calculate Federal tax that is 5% } totalTax=State+Federal; Net = Salary-totalTax; // Consume the remaining newline. keyboard.nextLine();

//Code Statements to Display Paycheck

Employee Name Employee Salary Federal Tax State Tax Total Tax Net pay // Does the user want to average another set? System.out.println("Would you like to process " + "another payroll?"); System.out.print("Enter Y for yes or N for no: "); input = keyboard.nextLine(); // Read a line. repeat = input.charAt(0); // Get the first char. } System.out.println(" Thank you for processing payroll "); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

relations with the local community and interest groups,

Answered: 1 week ago