Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using javaFX, write a program to store pairs of each state and its capital in a

ID: 3766654 • Letter: U

Question

Using javaFX, write a program to store pairs of each state and its capital in a map. Your program should prompt the user
to enter a state and should display the capital for the state and an image of the state flag for each from jpg files in a folder on my desktop. No command line programs here, only JavaFX pls pls

Here's a sample run:

FIGURE 8.10 A two-dimensional array stores states and their capitals.
   What is the capital of Alabama?
Montgomery plus the flag image of Alabama (the flag image can be found at the file name: Alabama.jpg)
  

What is the capital of Alaska?

Juneau plus the flag image of Alaska (the flag image can be found at the file name: Alaska.jpg)


     

Explanation / Answer

import java.util.HashMap;
import java.util.Iterator;

public class Map
{

    public static void main(String[] args) {

        
        Country Alabama=new Country("Alabama",2000);Montgomery
        Country Alaska=new Country("Alaska",20000);Juneau
        
        HashMap<country,string> countryCapitalMap=new HashMap<country,string>();
   
        countryCapitalMap.put(Alabama,"Montgomery");
        countryCapitalMap.put(Alaska,"Juneau");
        
        Iterator<country> countryCapitalIter=countryCapitalMap.keySet().iterator();
        while(countryCapitalIter.hasNext())
        {
            Country countryObj=countryCapitalIter.next();
            String capital=countryCapitalMap.get(countryObj);
            System.out.println(countryObj.getName()+"----"+capital);
            }
        }


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote