Class 10th ICSE

Q.9

Write a java 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 nameof the country along with its wonder,
otherwise display “Sorry Not Found!”
WONDERS TAJMAHAL,GREAT WALL OF CHINA,CHRIST THE REDEEMER,MACHUPICCHU,COLOSSEUM,PETRA,PYRAMID OFGIZA COUNTRIES INDIA,CHINA,BRAZIL,PERU,ROME,JORDAN,EGYPT

Solution :- 

import java.util.*;
class Wonders{
public static void main(){
Scanner sc =new Scanner(System.in);
int i,flag=0,pos=0;
String a[]={“INDIA”,”CHINA”,”BRAZIL”,”PERU”,”ROME”,”JORDAN”,”EGYPT”};
String b[]={“TAJMAHAL”,”GREAT WALL OF CHINA”,”CHRIST THE REDEEMER”,”MACHUPICCHU”,”COLOSSEUM”,”PETRA”,”PYRAMID OF GIZA”};
System.out.println(“Enter name of the country in capital letters”);
String country=sc.nextLine();
for(i=0;i<7;i++){
if(a[i].equals(country)){
flag=1;
pos=i;
break;
}
}
if(flag==1)
System.out.println(a[pos]+”,”+b[pos]);
else
System.out.println(“Sorry not found”);
}
}

Fun & Easy to follow
Works on all devices
Your own Pace
Super Affordable

Popular Videos

Play Video

UX for Teams

Learn the basics and a bit beyond to improve your backend dev skills.

ava4.png
Chris Matthews

Designer

Play Video

SEO & Instagram

Learn the basics and a bit beyond to improve your backend dev skills.

ava4.png
Chris Matthews

Designer