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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
OBJECT ORIENTED PROGRAMMING LESSON
LABORATORY EXERCISE-1
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
Example:
Enter your position: Manager
Enter your current salary: 10000
New salary: 11000
Raise Percentage
%10
%20
%15
%25
%23
Write your program using Java and copy your codes to a text file which has your name and
surname.
Then load it into UZEM under the provided link.
Transcribed Image Text:OBJECT ORIENTED PROGRAMMING LESSON LABORATORY EXERCISE-1 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 Example: Enter your position: Manager Enter your current salary: 10000 New salary: 11000 Raise Percentage %10 %20 %15 %25 %23 Write your program using Java and copy your codes to a text file which has your name and surname. Then load it into UZEM under the provided link.
Expert Solution
Step 1

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!");
        }                          
 }  
}  

 

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education