Lab - Programs Updated
Lab - Programs Updated
1. Write a Java program that prints all real and imaginary solutions to the quadratic equation
ax2 + bx + c = 0. Read in a, b, c and use the quadratic formula
2. Write a Java program to implement calculator operations
3. Write a java program to find prime factors of given number
Week-II
Week -III:
1. Write an application that uses String method indexOf to determine the total number of
occurrences of any given alphabet in a defined text.
2. Write a Java program to print all vowels in given string and count number of vowels and
consonants present in given string
3. Write an application that finds the substring from any given string using substring
method
Week-IV
1. Write a program to display details of the required employee based on his Id. The details
of employees includes, Emp_name, Emp_age, Emp_gender, Emp_designation,
Emp_salary, Emp_Address etc.
2. Implement the following case study using OOP concepts in Java.E-Book stall : Every
book has Properties i.e. Book_Name, Book_Author, Book_Count ; Every Customer has
properties as : Customer_Id, Customer_Name,Customer_Address and he can buy Books
from the E-Book stall by giving book name, author name and number of books he/she
want to buy .Write a Program which will display the list books bought by the customer
and remaining text books in the E-book stall with the count.
Week-V
1. Write an application that prompts the user for the radius of a circle and uses a method
called circleArea to calculate the area of the circle and uses a method circlePerimeter to
calculate the perimeter of the circle.
2. Create a class Account with an instance variable balance (double). It should contain a
constructor that initializes the balance, ensuring that the initial balance is greater than 0.0.
Acct details: Acct_Name, Acct_acctno, Acct_Bal, Acct_Address.Create two methods
namely credit and debit, getBalance. The Credit adds the amount (passed as parameter)
to balance and does not return any data. Debit method withdraws money from an
Account. GetBalance displays the amount. Ensure that the debit amount does not exceed
the Account’s balance. In that case the balance should be left unchanged and the method
should print a message indicating“Debit amount exceeded account balance”.
Week-VI
1. Write a Java program to find Area and Circle of different shapes using polymorphism
concept
2. Write a Java program which can give example of Method overloading and overriding
3. Write an application to create a super class Employee with information first name & last
name and methods getFirstName(), getLastName() derive the subclasses
ContractEmployee and RegularEmployee with the information about department,
designation & method displayFullName() , getDepartment(), getDesig() to print the
salary and to set department name & designation of the corresponding sub-class objects
respectively.
Week-VII
1. Create an abstract class Shape which calculates the area and volume of 2-d and 3-d
shapes with methods getArea() and getVolume(). Reuse this class to calculate the area
and volume of square ,circle ,cube and sphere.
2. Create an Interface payable with method getAmount ().Calculate the amount to be paid
to Invoice and Employee by implementing Interface.
3. Create an Interface StudentFee with methods getAmount(), getFirstName(),
getLastName() , getAddress(), getContact(). Calculate the amount paid by the Hostler
and Non Hostler student by implementing interface Student Fee
Week-VIII
1. Program for demonstrating the use of throw, throws & finally - Create a class with a
main( ) that throws an object of class Exception inside a try block. Give the constructor
for Exception a String argument. Catch the exception inside a catch clause and print the
String argument. Add a finally clause and print a message to prove you were there.
2. Write a program that shows that the order of the catch blocks is important. If you try to
catch a superclass exception type before a subclass type, the compiler should generate
errors.
Week-X
1. Write a program to create MyThread class with run() method and then attach a thread to
this MyThread class object.
2. Write a Program using Threads to simulate a traffic light. The Signal lights should glow
after each 10 seconds, one by one. For example: Firstly Red, then after 10 seconds, red
will be put off and yellow will start glowing and then accordingly green.
3. Write a Program using Threads for the following case study: Movie Theatre To watch a
movie the following process is to be followed, at first get the ticket then show the
ticket. Assume that N persons are trying to enter the Theatre hall all at once, displaying
their sequence of entry into the theater. Note: The person should enter only after getting a
ticket and showing it to the boy.