Skip to content

Automation Testing

Java, Selenium etc..

  • Java
  • Selenium
  • Interview Question
  • Core Java Coding
  • Rest APIS
  • Manual Testing
  • SQL Queries
  • Postman
  • Toggle search form

Create a Java program to store the Name and Salary of employees

Posted on May 12, 2023May 25, 2023 By admin
//Create a Java program to store the Name and Salary of employees
    //Name = [‘Ram’,’Rahim’,’Sid’,’Tom’]
    //Salary = [30000,20000,35000,23000]
    //
    //1. Add a new employee to the dictionary with name as ‘Shankar’ and salary as 15000
    //2. Update the salary of tom to 25000
    //3. List the names of employees who earn more than 20000
package InterViewQuestions;

import java.util.HashMap;
import java.util.Map;

public class TestClassSunMicrosystem {
 
    public static void main(String[] args) {
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        map.put("Ram", 30000);
        map.put("Ratan", 20000);
        map.put("Sid", 35000);
        map.put("Tom", 23000);
        map.put("Shander", 25000);

        //update the salary and print more then 20k salary users
        for (Map.Entry entry : map.entrySet()) {
            map.replace("Tom", 25000);
            String str = entry.getValue().toString();
            int salary = Integer.parseInt(str);
            //System.out.println("The Value is : "+salary);
            if (salary > 20000) {
                System.out.println(entry.getKey() + " " + entry.getValue());
            }
        }
    }
}
Core Java Coding Questions

Post navigation

Previous Post: String Char Counts Using Collections
Next Post: Imp Links

Recent Posts

  • Can you write java program for prime number 1to 50 and skip printing 30 and 40 numbers
  • Java 8 features
  • Imp Links
  • Create a Java program to store the Name and Salary of employees
  • String Char Counts Using Collections

Recent Comments

No comments to show.

Copyright © 2022 okhalaTech