0
How to create a java program that allows users to input employees monthly salary and numbers of years in service
Java
4 ответов
+ 4
Try self. And learn about how to take input from user in Java.
Learn Scanner in java.
+ 1
But may i ask whats wrong on my program? AJ Anant and Martin Taylor
import java.util.*;
public class MargieSalary {
public static void main(String[] args) {
int years, increase = 0, salary, total = 0;
Scanner kb = new Scanner(System.in);
System.out.println("Years of Service \t\t\t Salary Increase");
System.out.println("20 years or more \t = \t Php 13,000.00");
System.out.println("15 to 19 years \t = \t Php 10,000.00");
System.out.println("9 to 14 eyars \t\t = \t Php 8,000.00");
System.out.println("3 to 8 years \t\t = \t Php 5,000.00");
System.out.println("Less than 3 years = \t Php 2,000.00\n");
System.out.print("Employee's Monthly Salary: ");
salary = kb.nextInt();
System.out.print("Number of Years in Service: ");
years = kb.nextInt();
if(years >= 20) {
increase = 13000;
total = salary + increase;
}
else if(years >= 15 && years <= 19) {
+ 1
{
increase = 10000;
total = salary + increase;
}
else if(years >= 9 && years <= 14) {
increase = 8000;
total = salary + increase;
}
else if(years >= 3 && years <= 8) {
increase = 5000;
total = salary + increase;
}
else if(years < 3) {
increase = 2000;
total = salary + increase;
}
else System.out.println("PLEASE ENTER A VALID INPUT !");
System.out.println("Employee's Updated Monthly Salary: " + salary + " + " + increase + " = " + total);
}
}
0
Thank you for the answer 😊