Page 115 - ComputerScience_Class_11
P. 115

9              roll_no=0;
                  10              comp_m=0;

                  11              math_m=0;
                  12              total_m=0;
                  13          }

                  14          void accept()

                  15          {
                  16              Scanner sc = new Scanner(System.in);
                  17              System.out.print("Enter name of the student : ");

                  18              name=sc.nextLine();
                  19              System.out.print("Enter roll number of the student : ");

                  20              roll_no=sc.nextInt();
                  21              System.out.print("Enter computer marks of the student : ");

                  22              comp_m=sc.nextInt();
                  23              System.out.print("Enter math marks of the student : ");

                  24              math_m=sc.nextInt();
                  25          }

                  26          double calculate_marks()
                  27          {

                  28              total_m=comp_m+math_m;
                  29              return total_m/2.0;
                  30          }

                  31          void display_result()
                  32          {
                  33              System.out.println("---------------------------------------");

                  34               System.out.println("Name "+"\t"+"Roll"+"\t"+"Computer Marks "+"\t"+"Maths
                                    Marks");
                  35              System.out.println(name+"\t"+roll_no+"\t"+comp_m+"\t\t"+math_m);
                  36              System.out.println("Average Marks "+"\t"+"Total Marks ");

                  37              System.out.println( calculate_marks() +"\t\t"+ total_m);

                  38               System.out.println("----------------------------------------------------------
                                    ---------");
                  39          }

                  40          public static void main(String[] args)
                  41          {
                  42              student st1=new student();

                  43              student st2=new student();



                                                                                                          Objects  113
   110   111   112   113   114   115   116   117   118   119   120