Computer Science, asked by bhan61, 1 year ago



Question: Hello Capitals

You and your friends want to travel the capitals of 10 countries. The problem is, you and your friends are not good at geography. You are asked to write a program that will tell you the capital you want to visit. Here are the list of 10 countries, with their capital city:

Sweden: Stockholm

Australia: Canberra

New Zealand: Wellington

Netherlands: Amsterdam

Canada: Ottawa

Norway: Oslo

Jordan: Amman

Finland: Helsinki

Romania: Bucharest

Columbia: Bogota

Write a method Met that takes as parameter a String and prints the capital of the country.

Only write the method - assume that the Class & main method have been defined.

Use the System.out.println() statement for printing.

Example Input: Sweden
Output: Stockholm
Example Input: Canada
Output: Ottawa


nitish8089: use Hash map...

Answers

Answered by yogeshbishnoi289
0
input:india
output:delhi
Answered by nitish8089
1

complete \: code.......
import java.util.HashMap;
import java.util.Scanner;
public class Program
{

public static void met(String state){
HashMap<String, String> state_capital=new <String, String> HashMap();
state_capital.put("Sweden", "Stockholm");
state_capital.put("Australia", "Canberra");
state_capital.put("New zeland","Wellington");
state_capital.put("Canada","Otawa");
state_capital.put("Norway", "Oslo");
state_capital.put("Jordan", "Amman");
state_capital.put("Finland", "Helsiniki");
state_capital.put("Romania","Bucharest");
state_capital.put("coulmbia", "Bogota");
System.out.println(state_capital.get(state));
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String state=sc.next();
Program.met(state);
}
}

bhan61: please send me the answer for a method taking one integer with double digit number converting numbers to words, please send it tonight, don't forget, please don't mind
Similar questions