top of page

Java Programs To Practice - Salary Increment Planner

Updated: Dec 17, 2023


Java Programs To Practice

Explore a diverse collection of Java programs to practice and enhance your coding skills. From fundamental concepts to advanced algorithms, our Java programming exercises offer a hands-on learning experience. Elevate your proficiency with these practice programs, designed to sharpen your problem-solving abilities and reinforce your understanding of Java programming concepts. Start coding and mastering Java through a curated selection of practical exercises tailored for learners of all levels. create a Java application Salary Increment Planner that helps employees and HR departments plan salary increments and adjustments based on performance, seniority, or promotions. Create necessary model classes and the main program separately.


Core Java Programming

Java Back-End Development


//Model class: Employee.java

class Employee {

private String name;

private double currentSalary;

private int yearsOfExperience;

private boolean hasPromotion;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public double getCurrentSalary() {

return currentSalary;

}

public void setCurrentSalary(double currentSalary) {

this.currentSalary = currentSalary;

}

public int getYearsOfExperience() {

return yearsOfExperience;

}

public void setYearsOfExperience(int yearsOfExperience) {

this.yearsOfExperience = yearsOfExperience;

}

public boolean isHasPromotion() {

return hasPromotion;

}

public void setHasPromotion(boolean hasPromotion) {

this.hasPromotion = hasPromotion;

}

}



class SalaryIncrementCalculator {

// Constants for performance and seniority weights

private static final double PERFORMANCE_WEIGHT = 0.6;

private static final double SENIORITY_WEIGHT = 0.4;


public static double calculateIncrement(Employee employee) {

// Perform calculations based on performance, seniority, promotions, etc.

double performanceBonus = PERFORMANCE_WEIGHT * employee.getCurrentSalary(); // * performance factor */;

double seniorityBonus = SENIORITY_WEIGHT * employee.getCurrentSalary(); // * seniority factor */;


double totalIncrement = performanceBonus + seniorityBonus;


if (employee.isHasPromotion()) {

// Add additional bonus for promotion

double promotionBonus = 1000;

totalIncrement += promotionBonus; // * promotion bonus */;

}


return totalIncrement;

}

}


Core Java Programming

Java Back-End Development


//Main program

import java.util.Scanner;

public class SalaryIncrementPlanner {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);


// Get employee information

System.out.print("Enter employee name: ");

String name = scanner.nextLine();


System.out.print("Enter current salary: ");

double currentSalary = scanner.nextDouble();


System.out.print("Enter years of experience: ");

int yearsOfExperience = scanner.nextInt();


System.out.print("Has the employee been promoted? (true/false): ");

boolean hasPromotion = scanner.nextBoolean();


// Create an Employee object

Employee employee = new Employee();

employee.setName(name);

employee.setCurrentSalary(currentSalary);

employee.setYearsOfExperience(yearsOfExperience);

employee.setHasPromotion(hasPromotion);


// Calculate salary increment

double increment = SalaryIncrementCalculator.calculateIncrement(employee);


// Display the result

System.out.println("Salary increment for " + employee.getName() + ": $" + increment);


// Close the scanner

scanner.close();

}

}


6 views0 comments

コメント


bottom of page