Skip to content

Chapter 4 / hometask 4 #1

Description

@Amachuarori

Hometask was rejected for 2 times, and cant understand why, coz the main task is performing. Hope, u'll help , thanks!
the conditions are:

  1. Return to your 2nd homework assignments, when you described your favorite song.

  2. Refactor that code so all the variables are held as in a single data structure as keys and values.

  3. Refactor your print statements so that you have a single loop that passes through each item in the data structure and prints out it's key and then it's value.


program

String sname = "I think I just died";
String rating = "A"; /* rating is measuring from u to a (U,F,E,D,C,B,A) */
String worldRanking = "4";
String homeCountryRanking = "5";
String averageRanking = "4.5";
String genre = "pop";

    Map<String, String> description = new HashMap<>();
    description.put("SongName" , sname);
    description.put("Rating" , rating);
    description.put("WorldRank" , worldRanking);
    description.put("HomeRank" , homeCountryRanking);
    description.put("Average" , averageRanking);
    description.put("genre" , genre);
    for(Map.Entry<String, String> item : description.entrySet()){
        System.out.println(item.getKey() + " " +  item.getValue());
    }

home4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions