Boyan5

Title 17 homework

Apr 4th, 2021 (edited)
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.32 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Scanner;
  3.  
  4. public class grp {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         System.out.println("Please enter a choice:");
  8.         System.out.println("Choice 1: Enter a group to print the album");
  9.         System.out.println("Choice  2: Enter an album to print the group");
  10.         int choice = scanner.nextInt();
  11.         if (choice == 1) {
  12.             HashMap<String, String> grups = new HashMap<String, String>();
  13.             grups.put("Dire Straits", "Money for nothing");
  14.             grups.put("Queen", "Queen");
  15.             grups.put("Linkin park", "Meteora");
  16.             grups.put("Nirvana", "Nevermind");
  17.             grups.put("Pink Floyd", "The Wall");
  18.             grups.put("Beatles", "Help!");
  19.             grups.put("Led Zeppelin", "Led Zeppelin");
  20.             grups.put("Aerosmith", "Pump");
  21.             grups.put("Deep Purple", "Burn");
  22.             grups.put("Nickelback", "Dark Horse");
  23.             System.out.println("Enter a group, type \"end\" to stop: ");
  24.             String a = "";
  25.  
  26.             while (!a.equals("end")) {
  27.                 a = scanner.next();
  28.                 String m = a.substring(0, 1).toUpperCase() + a.substring(1);
  29.                 System.out.println(grups.get(a));
  30.             }
  31.             System.out.println("Have a nice day!");
  32.             }
  33.             if (choice == 2) {
  34.             HashMap<String, String> gr = new HashMap<String, String>();
  35.             gr.put("Money for nothing", "Dire Straits");
  36.             gr.put("Queen", "Queen");
  37.             gr.put("Meteora", "Linkin park");
  38.             gr.put("Nevermind", "Nirvana");
  39.             gr.put("The Wall", "Pink Floyd");
  40.             gr.put("Help!", "Beatles");
  41.             gr.put("Led Zeppelin", "Led Zeppelin");
  42.             gr.put("Pump", "Aerosmith");
  43.             gr.put("Burn", "Deep Purple");
  44.             gr.put("Dark Horse", "Nickelback");
  45.             System.out.println("Enter an album, type \"end\" to stop: ");
  46.             String b = "";
  47.             while (!b.equals("end")) {
  48.                 b = scanner.next();
  49.                 String p = b.substring(0, 1).toUpperCase() + b.substring(1);
  50.                 System.out.println(gr.get(b));
  51.             }
  52.             System.out.println("Have a nice day!");
  53.         }
  54.     }
  55. }
Add Comment
Please, Sign In to add comment