Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Scanner;
- public class grp {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Please enter a choice:");
- System.out.println("Choice 1: Enter a group to print the album");
- System.out.println("Choice 2: Enter an album to print the group");
- int choice = scanner.nextInt();
- if (choice == 1) {
- HashMap<String, String> grups = new HashMap<String, String>();
- grups.put("Dire Straits", "Money for nothing");
- grups.put("Queen", "Queen");
- grups.put("Linkin park", "Meteora");
- grups.put("Nirvana", "Nevermind");
- grups.put("Pink Floyd", "The Wall");
- grups.put("Beatles", "Help!");
- grups.put("Led Zeppelin", "Led Zeppelin");
- grups.put("Aerosmith", "Pump");
- grups.put("Deep Purple", "Burn");
- grups.put("Nickelback", "Dark Horse");
- System.out.println("Enter a group, type \"end\" to stop: ");
- String a = "";
- while (!a.equals("end")) {
- a = scanner.next();
- String m = a.substring(0, 1).toUpperCase() + a.substring(1);
- System.out.println(grups.get(a));
- }
- System.out.println("Have a nice day!");
- }
- if (choice == 2) {
- HashMap<String, String> gr = new HashMap<String, String>();
- gr.put("Money for nothing", "Dire Straits");
- gr.put("Queen", "Queen");
- gr.put("Meteora", "Linkin park");
- gr.put("Nevermind", "Nirvana");
- gr.put("The Wall", "Pink Floyd");
- gr.put("Help!", "Beatles");
- gr.put("Led Zeppelin", "Led Zeppelin");
- gr.put("Pump", "Aerosmith");
- gr.put("Burn", "Deep Purple");
- gr.put("Dark Horse", "Nickelback");
- System.out.println("Enter an album, type \"end\" to stop: ");
- String b = "";
- while (!b.equals("end")) {
- b = scanner.next();
- String p = b.substring(0, 1).toUpperCase() + b.substring(1);
- System.out.println(gr.get(b));
- }
- System.out.println("Have a nice day!");
- }
- }
- }
Add Comment
Please, Sign In to add comment