Page 247 - Cs_withBlue_J_C11_Flipbook
P. 247

28              System.out.println("Average:"+ avg_marks);
                  29          }

                  30          public static void main(String args[])
                  31          {

                  32              student_marks ob=new student_marks();
                  33              ob.accept();

                  34              ob.compute();
                  35              ob.display();
                  36          }

                  37      }

                 The output of the preceding program is as follows:
                   Enter your name:
                   PRIYANSHU SAHA
                   Enter marks in 2 subjects:
                   99
                   98
                   Enter your age:
                   16
                   Name of the student : PRIYANSHU SAHA Age : 16
                   Marks:99,98
                   Maximum Marks:99
                   Average:98.5


                   Program 5     Design a class called Banking_system with the following specifications:
                                 Data Members
                                 cus_name              :   to store the name of the depositor
                                 accno                 :   to store the account number
                                 type_acc              :   to store the type of the account(s/c)
                                 bal                   :   to store the balance amount in the account
                                 Member Functions
                                 void input( )         :   to input data to all the data members
                                                          (Minimum balance Rs.1000)
                                 void deposit(int d)    :   to deposit the amount d and update the balance
                                 void withdraw(int w)   :   to withdraw the amount a and update the balance
                                 void print( )         :   to print all the details
                                 Write the main method to create an object of the class and call the above methods.

                   1      import java.util.*;
                   2      class Banking_system    {

                   3          String cus_name;
                   4          long acno;

                   5          char type_acc;



                                                                                                                       245
                                                                                              Methods and Constructors  245
   242   243   244   245   246   247   248   249   250   251   252