Home / Programs / 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 the name of the country along with its Wonder, otherwise display "Sorry not found!". Seven Wonders: CHICHEN ITZA, CHRIST THE REDEEMER, TAJ MAHAL, GREAT WALL OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM Locations: MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY Examples: Country name: INDIAOutput: TAJ MAHAL Country name: USAOutput: Sorry Not found!
Programming Example

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 the name of the country along with its Wonder, otherwise display "Sorry not found!".

Seven Wonders:
CHICHEN ITZA, CHRIST THE REDEEMER, TAJ MAHAL, GREAT WALL OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM

Locations:
MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY

Examples:
Country name: INDIA
Output: TAJ MAHAL

Country name: USA
Output: Sorry Not found!

👁 233 Views
💻 Practical Program
📘 Step by Step Learning
Study this program carefully to understand the logic, output, and explanation in a structured way.

Information & Algorithm

Given Input:


Expected Output:


Program Code

import java.util.Scanner;

public class RAnsari7Wonders
{
    public static void main(String args[]) {
        
        String wonders[] = {"CHICHEN ITZA", "CHRIST THE REDEEMER", "TAJMAHAL", 
            "GREAT WALL OF CHINA", "MACHU PICCHU", "PETRA", "COLOSSEUM"};
        
        String locations[] = {"MEXICO", "BRAZIL", "INDIA", "CHINA", "PERU", "JORDAN",
        "ITALY"};
        
        Scanner in = new Scanner(System.in);
        System.out.print("Enter country: ");
        String c = in.nextLine();
        int i;
        
        for (i = 0; i < locations.length; i++) {
            if (locations[i].equals(c)) {
                System.out.println(locations[i] + " - " + wonders[i]);
                break;
            }
        }
        
        if (i == locations.length)
            System.out.println("Sorry Not Found!");
    }
}

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.