QuestionQuestion

Observe the following code, which creates a simple hashtable.

// Demonstrate a Hashtable
import java.util.*;
class HTDemo
{
public static void main(String args[])
{
Hashtable<String,Integer> numbers = new
Hashtable<String,Integer>();

numbers.put("one", new Integer(1));
numbers.put("two", new Integer(2));
}
}

Starting with this provided code, add the following functionality:
Add the numbers 3 through 10 to the hashtable continuing in the same manner as shown.
Prompt the user for a string, and display the corresponding number. For example, if the user types “five”, the program would output “5”. This must be done using the hashtable as created in the previous step.
Using a loop and a single println statement, display all of the values (both strings and integers) in a table.

Compile, run, and check the results. Submit the following:
The source file (If more than one file has been created, zip them into one .zip file for posting.)
An MS .doc file with explanations/comments of your solution and the results of a test run, including a screen shot picture
The UML class diagram of the application should be included in the deliverable as a part of the MS .doc above, or as a separate file.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

// Prompt the user for a string, and display the corresponding number.
       Scanner scanner = new Scanner(System.in);
       System.out.print("Enter a string: ");
       String s = scanner.next();
       if (numbers.containsKey(s)) {
            System.out.println(numbers.get(s));
       }...
$25.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats