Page 273 - CA_Blue( J )_Class10
P. 273

16          System.out.println("Enter your age:");
                  17          age=sc.nextInt();

                  18      }
                  19

                  20      void display()
                  21      {

                  22          System.out.println("Name:"+name);
                  23          System.out.println("Age:"+age);

                  24          System.out.println("Marks:"+m1+","+m2+ "and" +m3);
                  25          System.out.println("Maximum Marks:"+max);

                  26          System.out.println("Average:"+ avg);
                  27      }
                  28      void compute()

                  29      {

                  30          max=(m1>m2)?(m1>m3)?m1:m3:(m2>m3)?m2:m3;
                  31          avg=(m1+m2+m3)/3.0f;
                  32      }

                  33
                  34      public static void main(String args[])

                  35      {
                  36          Student1 ob=new Student1();

                  37          ob.input();
                  38          ob.compute();

                  39          ob.display();
                  40      }

                  41  }


                       Note: Since method names are not given, any names can be used.




















                                                                                                                       271
                                                                                      Class as the Basis of all Computation  271
   268   269   270   271   272   273   274   275   276   277   278