0% found this document useful (0 votes)
3 views1 page

Question

The document outlines the creation of an Employee class with attributes for name, age, and salary, including getters, setters, and a parameterized constructor. It also describes a Solution class with a main method that implements two static methods: calculateYearlySalary, which computes the yearly salary based on a 12-month work year, and calculateTax, which calculates tax based on specified salary brackets. The main method reads employee attributes using a Scanner and prints the calculated yearly salary and tax amount.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Question

The document outlines the creation of an Employee class with attributes for name, age, and salary, including getters, setters, and a parameterized constructor. It also describes a Solution class with a main method that implements two static methods: calculateYearlySalary, which computes the yearly salary based on a 12-month work year, and calculateTax, which calculates tax based on specified salary brackets. The main method reads employee attributes using a Scanner and prints the calculated yearly salary and tax amount.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Create a class Employee with the following attributes:

name (string)
age (int)
salary (double)
Write getters, setters, and a parameterized constructor in the above-mentioned
attribute sequence as required.

Create a class Solution with the main method.

Implement two static methods - calculateYearlySalary and calculateTax in the


Solution class.

calculateYearlySalary method:
-----------------------------------------
This method will take an Employee object as input.
The method will calculate the yearly salary of the employee (assuming that the
employee works for 12 months in a year) and
return it as a double.

calculateTax method:
-----------------------------------------
This method will take an Employee object as input.
The method will calculate the tax to be paid by the employee based on the following
rules:

If the yearly salary is less than or equal to 50000, the tax is 10% of the yearly
salary.
If the yearly salary is greater than 50000 but less than or equal to 100000, the
tax is 20% of the amount over 50000 plus 10%
of the first 50000.
If the yearly salary is greater than 100000, the tax is 30% of the amount over
100000 plus 20% of the amount between 50000 and
100000 plus 10% of the first 50000.
The method will return the tax amount as a double.
These above-mentioned static methods should be called from the main method.

For calculateYearlySalary method - The main method should print the yearly salary
returned by the method.

For calculateTax method - The main method should print the tax amount returned by
the method.

Before calling these static methods in main, use a Scanner object to read the
values of an Employee object's attributes.

Example Input:
----------------
John
30
55000.0

Example Output:
----------------
Yearly salary of John: 660000.0
Tax to be paid by John: 183000.0

You might also like