English

Write a Program to Initialize the Seven Wonders of the World Along with Their Locations in Two Different Arrays. Search for a Name of the Country Input by the User. If Found, Display - Computer Applications

Advertisements
Advertisements

Question

Write a program to initialize the seven Wonders of the World along with their locations in two different arrays. Search for the name of the country input by the user. If found, display the name of the country along with its Wonder, otherwise display “Sorry Not Found!”. 
Seven wonders — CHICHEN ITZA, CHRIST THE REDEEMER, TAJMAHAL, GREAT WALL OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations — MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY
Example

Country Name: INDIA     Output: INDIA-TAJMAHAL
Country Name: USA        Output: Sorry Not Found!

Answer in Brief
Advertisements

Solution

import java.util.Scanner;
class test
{
            public static void main()
{
            String w [] = {"Chichen Itza", "Christ The Redeemer", "Taj Mahal", "Great wall of china", "Machu Picchu"; "Petra Colosseum"};
            String L [] = {"Mexico, "Brazil", "India", "China", "Peru", Jordan", "Italy"};
Scanner sc = new Scanner (System.in);
System.out.println ("Enter country Name");
String c = sc.next();
boolean found = false;
for (int i = 0; i<w.length(); i++)
{
          if (L [i].equalsIgnoreCase(c))
          {
              found = true;
              System.out.println (L[i] + "-" + w[i]);
              break;
          }
}
             if(found = = false)
             System.out.println ("Sorry Not found");
}
}

shaalaa.com
  Is there an error in this question or solution?
2015-2016 (March)

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×