Computer Science, asked by npafho4880, 9 months ago

write a java program to initialize the seven wonders of the world along with their locations in two different array search for a name of the country by the user. if found display the name of the country its wonders, other wise display sorry not found !

Answers

Answered by suskumari135
10

java program to initialize the seven wonders of the world along with their locations in two different array search for a name of the country by the user. if found display the name of the country its wonders, other wise display sorry not found !

Explanation:

Java program

import java.util.Scanner;

public class SevenWonders {

   public static void main(String[] args) {  

   Scanner sc = new Scanner(System.in);

   String[] w = { "CHICHEN ITZA", "CHRIST THE RDEEEMER", "TAJMAHAL",  "GREAT WALL OF CHINA",  "MACHU PICCHU", "PETRA", "COLOSSEUM" };

   String[] l = { "MEXICO", "BRAZIL", "INDIA", "CHINA", "PERU", "JORDAN", "ITALY" };

    System.out.print("Enter name of the country: ");

    String ch = sc.next();

    int index = -1;  

    for (int i = 0; i < l.length; i++) {

     if (l[i].equals(ch)) {

index = i;

   }

}

if (index != -1) {

System.out.println(l[index] + " - " + w[index]);

}  

else {

System.out.println("Sorry Not Found!");

}

}

}

Output

Enter name of the country: INDIA

INDIA - TAJMAHAL

Similar questions