ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2016 ICSE Computer Science Paper



Share with a Friend

Solved 2016 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Two Different Arrays Program - ICSE 2016 Computer Science

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!

import java.util.Scanner; class Search{ public static void main(String[] args){ Scanner in = new Scanner(System.in); 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"}; System.out.print("Country name: "); String c = in.nextLine().toUpperCase(); int i = 0; while(i < w.length){ if(c.equals(l[i])) break; i++; } if(i == w.length) System.out.println("Sorry not found!"); else System.out.println(l[i] + " - " + w[i]); } }

Output

 
 OUTPUT 1: 
Country name: INDIA
INDIA - TAJ MAHAL 

 OUTPUT 2: 
 Country name: USA
Sorry not found!