Course Name : Programming Java
Course Code : CSC 384
Faculty’s Name : Rubayea Ferdows
Section : A & B
List of Programs for Lab Report
   1. Implement inheritance
              ● Create a class Calculation that has an integer variable z, method addition(int x,
                  int y) that assigns the addition of x and y to z and print the value of z. Method
                  Subtraction(int x, int y) that assigns the subtraction of x and y to z and prints
                  the value of z.
              ● Create class My_Calculation that extends from Calculation. My_Calculation
                  will have a method multiplication(int x, int y) that assigns the multiplication of
                  x and y to z and prints the value of z.
              ● Write main method in which create objects of My_Calculation and call
                  addition, Subtraction and multiplication methods using the object.
   2.   Define a Super class named Point containing: - An instance variable named x of type
        int. - An instance variable named y of type int. - Declare a method named
        toString()Returns a string representation of the point. - Constructor that accepts values
        of all data members as arguments. Define a Subclass named Circle. A Circle object
        stores a radius (double) and inherits the (x, y) coordinates of its center from its superclass
        Point. Each Circle object should have the following public methods:
           ● Circle(x, y, radius) Constructs a new circle with a center specified by the given
               coordinators x,y and with the given double radius.
           ● getArea()
               Returns the area occupied by the circle, using the formula πr2.
           ● getCircumference()
               Returns the circle's circumference (distance around the circle), using the formula
               2πr.
       ● toString()
           Returns a string representation of the circle, such as "Circle[center=(75, 20);
           radius=30]".
3. Write a program that prompts a user for a String and prints the reverse of the String.
       ● Enter a String: reverse
       ● The reverse of the String "reverse" is "esrever".
4. Abstract Class A contains array1 and array2 methods where none of them have
   definition. Create a child class C that will have the body for the two array methods of 2
   dimensions. And then create a method called multiply inside Class C that will multiply
   the two dimensional arrays
5. Interface A has 2 methods. One of them will take the user input of a number and another
   method will identify whether the number is an automorphic number or not. Interface B
   also has two methods where in the same way one of them will take user input another
   will check whether the number is duck number or not. class C will implement all 4
   methods
6. Student A has given the admission test. If the mark is less than 40 then the program will
   throw arithmetic exceptions. But if the mark is 40 or more then the numbers of Math and
   Physics will be checked individually. If the mark is 20 in each subject then the student
   can get the admission in CSE dept. But for none of the subjects the student should get 0
   or none of the subject questions should remain unanswered. Otherwise it will show
   another exception.
7. Imagine a situation where you are driving a car. Your car has an automatic feature that
   tells you if any car is approaching your car from the opposite direction. One day you
   were running late for the office and started driving very fast and also took a shortcut on
   the wrong side of the road. Suddenly a car approached you from the opposite direction as
   you were on the wrong side. But due to the safety feature of your car you could avoid a
   life taking accident. Though some scratches were there in your car but you were not
   harmed because you got alarmed immediately before the crash occurred.
   Now write a program using the oop feature of java that will have similarity with the
   above scenario.
8.   Write a program to implement the ATM machine transaction system
     Features:
     a) user can withdraw money (less than the total amount)
      per transaction, the user gets the amount which is divisible by 500. and the minimum
     amount in the account without withdrawal is 500
     b) user can check balance
9. ABC Company has two types of employees - Manager and Programmer. Based on their
     role they have separate job responsibilities. The company calculates the salary of their
     employees. But the calculation formula for employees is different for different types of
     roles.
10. Imagine in your home you have a single kitchen which is used by all of your family
     members. You like to have bread and butter in your breakfast, your mother likes bread,
     vegetables and tea, your sister likes to have noodles and mango juice. But each of you are
     using the same kitchen everyday, only the preparation for each person is different.
11. Write a program for creating a Laptop. Name, Price, Processor, Ram and Hard drive
    should be defined in base class . You need to inherit these functionalities in your program
    and Print Details. All the laptops should have different name, price, processor, ram and
    hard drives. Output:
    Name : Lenovo
    Price : $1000
    Processor : i3
    Ram : 2GB
    HDD : 500G
    *************************************
    Name : Dell
    Price : $1500
    Processor : i5
    Ram : 4GB
    HDD : 1TB
    *************************************
    Name : Sony
    Price : $2000
    Processor : i9
    Ram : 8GB
    HDD : 1TB
    *************************************
12. Write down codes using the following instructions. If it is not possible then explain why.
       a. Write a class Animal with following properties:
           Fields (with data type):
                   - height: int
                   - weight: float
                   Methods:
                     void walk() { System.out.println(“I walk on the street”);}
       b. Write a get and set method for the fields of class Animal.
       c. Write a class Bird that inherits from Animal class.
       d. Write a constructor method for Bird class.
       e. Write an interface FlyingBird with following properties:
                   Methods:
                   void fly() {System.out.println(“I fly in the sky”)}
       f. Write a class Parrot that inherits Bird class and uses FlyingBird interface.
       g. Write a static method display() that shows the following message: “I am Mithu!”.
       h. Write a class Test. Inside the Test class create an object of Parrot class and call the
           static method display().
13. Write a program that prompts a user for a String, counts the number of vowels,
   consonants and digits (0-9) contained in the string and prints their number of
   occurrence and the percentages (with 2 decimal digits).
   Enter a String: testing12345
   Number of vowels: 2 (16.67%)
   Number of consonants: 5 (41.67%)
   Number of digits: 5 (41.67%)
14. Write a program called SharedCounter.java in which 10 threads each increment a shared
   int counter 10 times. When all the threads have finished, print the final value of the
   counter. If the initial value is zero, do you always get 100? Arrange for your code to
   sometimes print the wrong answer. (Hint: try using some well-placed calls to
   Thread.yield() or Thread.sleep().)
15. Create your own exception class using the extends keyword. Write a constructor for this
   class that takes a String argument and stores it inside the object with a String reference.
   Write a method that prints out the stored String. Create a try-catch clause to exercise
   your new exception.