CS 234 & IS 292: Practical One (Week 2 & 3 ) 10th June, 2019
1. Write a Java application program with the class name Pencil consisting of three instance variables color, length and price. The program has a single method called display which, when invoked using an object of the Pencil class, displays the values of the attributes associated with the pencil object.
2. Write a BankAccount java application program. When creating BankAccount objects, for example acc1 and acc2, the account number and account name of each account object should be set at the time the object is created. It should be possible to deposit amount of money into acc1 and into acc2. Use encapsulation techniques to ensure that sensible amount of money are deposited. When a user attempts to withdraw a certain amount e.g 150 from any of the account, the program must displays the message “WITHDRAWAL SUCCESSFUL” if the amount was withdrawn successfully and “INSUFFICIENT FUNDS” if it was not. It should be able to display the balance of acc1 and the balance of acc2.