Page 623 - ComputerScience_Class_11
P. 623

41              }
                   42
                   43              if (!found)
                   44              {

                                        System.out.println("Student with roll number " + rollnoToSearch +
                   45                    " not found.");
                   46              }
                   47              dis.close();
                   48          }
                   49          public static void main(String[] args) throws IOException
                   50          {
                   51              StudentBinaryFile obj = new StudentBinaryFile();
                   52              obj.createFile();
                   53              Scanner sc = new Scanner(System.in);
                   54              System.out.print("Enter roll number to search: ");
                   55              int rollnoToSearch = sc.nextInt();
                   56              obj.searchStudent(rollnoToSearch);
                   57          }
                   58      }

                 The output of the preceding program is as follows:
                       BlueJ: Terminal Window - Java

                   Options

                  Enter roll number: 101
                  Enter student name: Amit
                  Do you want to add another student? (y/n): Y
                  Enter roll number: 102
                  Enter student name: Amrit
                  Do you want to add another student? (y/n): N
                  Student records have been written to the file.
                  Enter roll number to search: 101
                  Student found: Roll No: 101, Name: Amit



                                                               PYTHON
                 29. Write a program to calculate simple interest.
                     Program 29.py

                  File  Edit  Format   Run   Options   Window     Help

                  p = float(input('Enter the principal: '))
                  r = float(input('Enter rate of interest: '))
                  t = float(input('Enter time duration in years: '))
                  si = (p * r * t) / 100
                  print('Simple Interest:', si)









                                                                                                Internal Assessment  621
   618   619   620   621   622   623   624   625   626   627   628