Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
Question
Book Icon
Chapter 21, Problem 21.9PE
Program Plan Intro

StateCapital.Java

Program Plan:

  • Include the class name named “StateCapital_Map”.
    • Declare the package.
    • Import the util package.
    • Define class.
    • Declare the main()method.
    • Create a Scanner.
    • Store 50 states and their capitals in a map.
    • Prompt the user to enter a state.
    • Check if state is present.
    • Close the main method.
    • Create another Method getData that stores the 50 states and their capitals in a map.
    • Define a new hashmap.
    • Declare a map data.
      • assign states along with their capitals
    • Create a loop to traverse through the entire data length.
      • Put each state with their capital in the data.
    • Return the map.
    • Print the user entered state along with their capital from the map.
    • Close the class.

Blurred answer
Students have asked these similar questions
What does the following code snippet do?
Write the following
What are the errors in the following code?
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning