Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help filling in the code with JAVA, import java.util.TreeMap; import java.util.Map; import java.util.Set; /** * Grades - Write a program that uses a TreeMap

Need help filling in the code with JAVA,

import java.util.TreeMap; import java.util.Map; import java.util.Set; /** * Grades - Write a program that uses a TreeMap to store a set of * names and their corresponding grades. Based upon P16.7 in Big Java */ public class Grades { private Map  grades; //-----------Start below here. To do: approximate lines of code = 2 // 1. Write a default constructor for the Grades class ; //2. use a TreeMap for the grades map. //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. /** * Adds a name and its corresponding grade. * @param name the name, which will be the key * @param grade the grade, which will be the value */ public void add(String name, String grade) { //-----------Start below here. To do: approximate lines of code = 1 // put this key value pair into grades //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } /** * Returns the grade for a given name. * @param name the name. * @return the grade corresponding to the specified name. */ public String getGrade(String name) { //-----------Start below here. To do: approximate lines of code = 1 // use the map to fetch the value given the key //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } /** * Removes a name and it's corresponding grade. * @param name the name to remove. */ public void remove(String name) { //-----------Start below here. To do: approximate lines of code = 1 // use the map to remove the key name //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } /** * Returns a String containing all of the names and their * corresponding grades formatted as: * name1: grade * name2: grade * @return all the names and their corresponding grades as a String */ public String toString() {  //-----------Start below here. To do: approximate lines of code = 5 // initialize the result string //let names be the set of keys //for each name //append the key: value pair followed by a newline //return the result string //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 23rd International Conference Dexa 2012 Vienna Austria September 2012 Proceedings Part 1 Lncs 7446

Authors: Stephen W. Liddle ,Klaus-Dieter Schewe ,A Min Tjoa ,Xiaofang Zhou

2012th Edition

3642325998, 978-3642325991

More Books

Students also viewed these Databases questions

Question

2. Describe how technology can impact intercultural interaction.

Answered: 1 week ago