Problem: Write a program that takes position and current salary value from the user and calculate the new salary and shows it on the console according to the following table. Position Manager Salesman Human Resources Technician Headman Raise Percentage %10 %20 %15 %25 %23
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:


Java Program:
import java.util.*;
class Salary
{
public static void main(String[] args)
{
// Takes the position as user input
Scanner sc= new Scanner(System.in);
System.out.print("Enter your position: ");
String position= sc.nextLine();
// Takes the salary as user input
System.out.print("Enter your current salary: ");
double salary = sc.nextDouble();
double S = 0, new_salary = 0;
switch (position) {
// if position is Manager
case "Manager":
// Then the raised percentage of Manager is 10%
S = salary * 0.10;
new_salary = salary + S;
System.out.println("New salary: " + new_salary);
break;
// if position is Salesman
case "Salesman":
// Then the raised percentage of Manager is 20%
S = salary * 0.20;
new_salary = salary + S;
System.out.println("New salary: " + new_salary);
break;
// if position is Human Resources
case "Human Resources":
// Then the raised percentage of Manager is 15%
S = salary * 0.15;
new_salary = salary + S;
System.out.println("New salary: " + new_salary);
break;
// if position is Technician
case "Technician":
// Then the raised percentage of Manager is 25%
S = salary * 0.25;
new_salary = salary + S;
System.out.println("New salary: " + new_salary);
break;
// if position is Headman
case "Headman":
// Then the raised percentage of Manager is 23%
S = salary * 0.23;
new_salary = salary + S;
System.out.println("New salary: " + new_salary);
break;
default:
// Display invalid input on screen if user enters wrong choice
System.out.println("Invalid Input!");
}
}
}
Step by step
Solved in 2 steps with 3 images









