Java

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

COMSATS University Islamabad

Attock Campus

Department Of Computer Science

Instructor Umer zia


Lab 04
Assignment

Submitted by:
Registration No. Name
FA23-BCS-061 M.Awais
public static double[] employee() {

Scanner scan = new Scanner(System.in);

System.out.println("enter the number of employee");

double p=scan.nextDouble();

double[] employee = new double[p];

for (int i = 0; i < p; i++) {

System.out.println("Enter the salary of imployee: " + (i + 1));

employee[i] = scan.nextDouble();

return employee;

public static double[] yearly_salary(double[] employee) {

double[] salary = new double[employee.length];

for (int i = 0;

i < salary.length; i++) {

salary[i] = employee[i] * 12;

return salary;

public static double[] calTax(double[] salary) {

double[] tax = new double[salary.length];

for (int i = 0; i < salary.length; i++) {

// double taxx=0;
if (salary[i] < 10000) {

tax[i] = 0;

} else if (salary[i] > 10000 && salary[i] < 5000) {

tax[i] = salary[i] * 0.1;

} else if (salary[i] > 50000 && salary[i] < 100000) {

tax[i] = salary[i] * 0.2;

} else if (salary[i] > 100000) {

tax[i] = salary[i] * 0.3;

return tax;

public static double[] TotalSalary(double[] salary, double[] tax) {

double[] tot_salary = new double[salary.length];

for (int i = 0; i < salary.length; i++) {

tot_salary[i] = salary[i] - tax[i];

return tot_salary;

public static void slariess() {

Scanner scan = new Scanner(System.in);

int p = 0;

int[] id = new int[p];


String[] name = new String[p];

for (int i = 0; i < p; i++) {

System.out.println("Enter the name of employee " + (i + 1) + " ");

scan.nextLine();

name[i] = scan.nextLine();

System.out.println("Enter the id of employee " + (i + 1) + " ");

id[i] = scan.nextInt();

double[] eemployee = employee();

double[] y_salary = yearly_salary(eemployee);

double[] tax = calTax(y_salary);

double[] t_salary = TotalSalary(y_salary, tax);

System.out.println("name \t ID \t monthly salary \t yearly salary \t Tax \t Total salary");

for (int i = 0; i < p; i++) {

System.out.println(name[i] + "\t" + id[i] + "\t" + eemployee[i] + " \t " + y_salary[i] + "


\t " + tax[i] + "3 \t" + t_salary[i]);

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Enter the number of employees");

int p = scan.nextInt();

slariess();

Output:

You might also like