Page 633 - Computer science 868 Class 12
P. 633

56
                 Enter choice

                 2
                 Deleting22

                 Enter choice
                 3

                 67
                 56

                 Enter choice
                 2

                 Deleting67
                 Enter choice

                 3
                 56
                 Enter choice

                 2
                 Deleting56

                 Enter choice
                 3

                 Enter choice
                 4

                 Exit


                   Program 23    HCF and LCM using Exception Handling
                                 Write a class named hcf_exception using the following description.
                                 Data Members
                                 int n1, n2                   :  to store the two number taken from the user
                                 int h                        :  to store HCF of n1 and n2
                                 int l                        :  to store Lcm of n2 and n2
                                 Member Functions
                                 void  entry()                :  takes two number from the user.
                                 void swap()                  :  used to store smaller number in n1
                                 void calculate()             :  calculates and return HCF
                                 void show()                  :  to display HCF and LCM of n1 and n2
                                 Use only java.util package and exception handling methods to prevent division by 0.


                   1       import java.util.*;
                   2       class hcf_exception





                                                                                                                       631
                                                                                                   Internal Assessment  631
   628   629   630   631   632   633   634   635   636   637   638