In: Computer Science
Using map - java - eclipse
Prompt the user for the skillset to add. A skillset can be any String. Examples of skillsets are: “java” “software design”, “databases”, etc.
Add the skillset to the logged in user’s skillsets and then provide a response to the logged in user indicating that their skillset has been added (e.g. “Java has been added to your skillsets.”). You don’t have to display any additional messages if the user added a duplicate skillset. In this assignment the case of the skillset doesn’t apply – meaning “JAVA” and “java” should be treated as two different skillsets
I have created a java project named skillset in eclipse.
package skillset;
import java.util.*;
public class skillSet {
public static void main(String[] args) {
Map<String, String> map = new HashMap<String, String>();
String usesrname = "user";
String skillset;
System.err.println("Enter q to terminate the program");
Scanner sc = new Scanner(System.in);
while (true){
System.out.println("Enter your skillset: ");
skillset = sc.nextLine();
//checks if user entered q then terminate the program
//otherwise goes in else loop and add skillset to map
if(skillset.equals("q")) {
break;
}
else {
map.put(usesrname, skillset);
}
//print statement
System.out.println(skillset + " has been added to your skill set");
}
}
}