Page 413 - CA_Blue( J )_Class10
P. 413

s = ar[i];
                                   sum += ar[i];
                               }
                                System.out.println("Sum = " + sum);
                                System.out.println("Largest number = " + l);
                                System.out.println("Smallest number = " + s);
                           }
                       }
                    19.  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!".                                                                          [2016]
                        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!
                   Ans.  import java.util.*;
                       class sevenWonders{
                           public static void main()
                           {
                                 Scanner sc = new Scanner(System.in);
                                String cname;
                                int i,pos=-1;
                                 String sw[] = {"CHICHEN ITZA", "CHRIST THE REDEEMER", "TAJ MAHAL", "GREAT WALL
                                 OF CHINA", "MACHU PICCHU", "PETRA", "COLOSSEUM"};
                                 String loca[] = {"MEXICO", "BRAZIL", "INDIA", "CHINA", "PERU", "JORDAN", "ITALY"};
                                 System.out.print("Country name: ");
                                cname = sc.nextLine();
                                for(i=0; i < sw.length; i++)
                                 {    if(cname.equalsIgnoreCase(loca[i]))
                                {   pos=i;
                                    break;
                                    }
                                }
                                if(pos!=-1)
                                     System.out.println(sw[i] + " –"  + loca[i]);
                                else
                                     System.out.println("Sorry not found!");
                           }
                       }
                    20.   Write  a  program  to  input  and  store  roll  numbers,  names  and  marks  in  3  subjects  of  n  number  of  students  in  five
                       single-dimensional arrays and display the remark based on average marks as given below:
                        Average marks = Total Marks ÷ 3                                                             [2015]
                        Average Marks        Remark
                        85 – 100                 EXCELLENT
                        75 – 84                  DISTINCTION
                        60 – 74                  FIRST CLASS
                        40 – 59                  PASS
                        Less than 40             POOR
                        The maximum marks in the subject are 100.
                   Ans.  import java.util.*;


                                                                                                                       411
                                                                                                              Arrays   411
   408   409   410   411   412   413   414   415   416   417   418