Page 368 - ComputerScience_Class_11
P. 368

36                  System.out.println("Updated list of students:");

                37                  for (int i = 0; i < size; i++)
                38                  {
                39                      System.out.print(" "+students[i]);

                40                  }
                41              }
                42              else

                43              {

                                     System.out.println("Name '" + nameToDelete +  "' not found in the
                44                    list.");
                45              }
                46              sc.close();
                47          }

                48      }

              The output of the preceding program is as follows:

                      BlueJ: Terminal Window - Java
                   Options

                  Enter the number of students: 5
                  Enter the names of 5 students:
                  Student 1: Aarav
                  Student 2: Aditya
                  Student 3: Aryan

                  Student 4: Siddharth
                  Student 5: Rahul
                  Enter the name to be deleted: Aarav
                  Name 'Aarav' has been deleted.
                  Updated list of students:
                  Aditya Aryan Siddharth Rahul





                Program 4      Create an array of size 4 and fill the array with the factorials of all the numbers between 1
                               and 4. Then, display the contents of the array.

                1       class FactorialArray
                2       {

                3           public static void main(String args[])
                4           {

                5               int i, f = 1;




                  366  Touchpad Computer Science (Ver. 3.0)-XI
   363   364   365   366   367   368   369   370   371   372   373