Answer to Question #266836 in Java | JSP | JSF for Dexter

Question #266836

Write a JAVA program that will compute for the net income of a particular employee. You have to accept name, position, and number of days worked. The position has three categories: if Manager, rate per day is P500; if Supervisor, P400; if Employee, P300. Then after accepting the rate per day, compute gross = rate per day * no. of days worked, compute for the bonus, if gross is >= 8000, bonus = 1000; if gross>= 5000, bonus = 750; if gross >= 3000, bonus = 500; if less, bonus = 0; compute for the deductions: SSS is always 10% of gross; Medicare is always P100; and TAX, if gross >= 7000, tax = 15% of gross; if gross >= 4000, tax = 10% of gross, if gross >=2000, tax = 5% of gross. Then, compute for Net Income = gross + bonus – total deduction. Then, display the net income. 


1
Expert's answer
2021-11-16T13:51:38-0500


import java.util.Scanner;


public class App {


	static double calculateBonus(double gross) {
		// if gross is >= 8000, bonus = 1000;
		if (gross >= 8000) {
			return 1000;
		}
		// if gross>= 5000, bonus = 750;
		else if (gross >= 5000) {
			return 750;
		}
		// if gross >= 3000, bonus = 500;
		else if (gross >= 3000) {
			return 500;
		}
		return 0;
	}


	static double calculateTax(double gross) {
		// TAX, if gross >= 7000, tax = 15% of gross;
		if (gross >= 8000) {
			return 0.15 * gross;
		}
		// if gross >= 4000, tax = 10% of gross,
		else if (gross >= 4000) {
			return 0.1 * gross;
		}
		// if gross >=2000, tax = 5% of gross.
		else if (gross >= 2000) {
			return 0.05 * gross;
		}
		return 0;
	}


	/**
	 * The start point of the program
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);
		double[] ratePerDay = { 500.0, 400.0, 300.0 };
		System.out.print("Enter employee name: ");
		String employeeName = keyBoard.nextLine();
		int ch = -1;
		while (ch < 1 || ch > 3) {
			System.out.println("1. Manager");
			System.out.println("2. Supervisor");
			System.out.println("3. Employee");
			System.out.print("Select position: ");
			ch = keyBoard.nextInt();
		}


		System.out.print("Enter employee number of days worked: ");
		double noDaysWorked = keyBoard.nextDouble();
		// gross = rate per day * no. of days worked
		double gross = ratePerDay[ch - 1] * noDaysWorked;
		// compute for the bonus,
		double bonus = calculateBonus(gross);
		// if less, bonus = 0;
		// compute for the deductions:
		// SSS is always 10% of gross;
		double deductions = 0.1 * gross;
		// Medicare is always P100;
		double medicare = 100.0;
		double tax = calculateTax(gross);


		// Then, compute for Net Income = gross + bonus – total deduction.
		double netIncome = gross + bonus - tax - medicare - deductions;
		// Then, display the net income.
		System.out.printf("\nEmployee name: %s\n", employeeName);
		System.out.printf("The gross: %.2f\n", gross);
		System.out.printf("The bonus: %.2f\n", bonus);
		System.out.printf("The tax: %.2f\n", tax);
		System.out.printf("The medicare: %.2f\n", medicare);
		System.out.printf("The net income: %.2f\n", netIncome);


		keyBoard.close();


	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS