Ex No1
Ex No1
Experiment No: 1
Develop a Java application to generate Electricity bill. Create a class with the following
members: Consumer no., consumer name, previous month reading, current month reading
,type of EB connection (i.e domestic or commercial). Compute the bill amount using the
following tariff.
If the type of the EB connection is domestic ,calculate the amount to be paid as follows:
First100 units -Rs. 1perunit
101-200units -Rs.2.50 per unit
201-500 units -Rs.4 per unit
Greaterthan501 units- Rs. 6perunit
If the type of the EB connection is commercial, calculate the amount to be paid as
follows:
First100 units -Rs. 2perunit
101-200units -Rs.4.50 per unit
201-500 units -Rs.6 per unit
Greaterthan501 units- Rs. 7perunit.
Aim
To implement class and object creation by developing a java programme for generating Electricity bill.
Generate Electricity bill by creating a class with the following members: Consumer no., consumer
Name, previous month reading, current month reading, type of EB connection (i.e. domestic or
commercial) and compute the bill amount using the following tariff.
If the type of the EB connection is domestic, calculate the amount to be paid as follows:
First 100 units - Rs. 1 per unit
101-200 units - Rs. 2.50 per unit
201 -500 units - Rs. 4 per unit
> 501 units - Rs. 6 per unit
If the type of the EB connection is commercial, calculate the amount to be paid as follows:
First 100 units - Rs. 2 per unit
101-200 units - Rs. 4.50 per unit
201 -500 units - Rs. 6 per unit
> 501 units - Rs. 7 per unit
Algorithm
1. Start the program
2. Create a class with the name Electricity Bill.
3. Get the details of the user and type of the connection.
4. Calculate the tariff based on the type of connection.
5. Compile and Execute the class “Electricity Bill”, and generate the appropriate output.
Presented in Board of Studies meeting held on --.04.2021(Approved)
Passed in the 1st Academic Council meeting dated --.04.2021
Form No.CD 02 C Rev.No.00 Effective Date: 1/06/2021
VEL TECH HIGH TECH
Dr. RANGARAJAN Dr. SAKUNTHALA ENGINEERING COLLEGE
(An Autonomous Institution, Affiliated to Anna University, Chennai)
R-2021 UG Syllabus for 21BT32T
PSEUDOCODE
Read a units
Read a usage type
IF usage_type equal “Residential”
IF units >0and units <=200 THEN
Bill= units*0.8
ELSE IF units >200 and units <=999 THEN
Bill= units*0.7
ELSE
Bill= units*0.5
END IF
END IF
ELSE
IF units >0and units <=200 THEN
Bill= units*0.6
Presented in Board of Studies meeting held on --.04.2021(Approved)
Passed in the 1st Academic Council meeting dated --.04.2021
Form No.CD 02 C Rev.No.00 Effective Date: 1/06/2021
VEL TECH HIGH TECH
Dr. RANGARAJAN Dr. SAKUNTHALA ENGINEERING COLLEGE
(An Autonomous Institution, Affiliated to Anna University, Chennai)
R-2021 UG Syllabus for 21BT32T
RESULT
Java program to generate electricity bill has been developed and was tested with sample
values.
VIVA-VOCE QUESTIONS
Experiment No: 2
Develop a java application to implement currency converter (Dollar to INR, EURO to INR,Yen to
INR and vice versa), distance converter (meter to KM, miles to KM and vice versa) ,time
converter(hours to minutes, seconds and vice versa) using packages.
Aim
To implement packages by writing a java programme for currency converter (Dollar to INR, EURO to
INR, Yen to INR and vice versa), distance converter (meter to KM, miles to KM and vice versa) , time
converter (hours to minutes, seconds and vice versa) .
Algorithm
1. Start the program
2. Create a class with the name Conversion
3. Create a Package with the name mypack1 and import the mypack1 in the conversion program
4. Create a class currency converter, distance converter, time converter in the package calledmypack1.
5. Call the currency converter, distance converter, time converter from the conversion class.
6. Get the details of the user for the corresponding conversion and print it.
7.Stop the Program
https://www.youtube.com/watc
VL - 2 switch Statement in Java h?v=wcwWlasmLWs
Neso Academy
https://www.youtube.com/watc
VL - 3 The Do While Loop in Java h?v=2E-UgePiOoo
Neso Academy
Currency Converter |
https://www.youtube.com/watc
Distance Converter | Time
VL - 4 h?v=crDuk6Y_Jig&t=60 RK Keynotes
Converter s
https://www.youtube.com/watch?v=
pPHBEYblDMw&list=PLZTETldy
VL - 2 switch Statement in Java guF0ZqpdwU3jM_UgHu7- Learn Programming Yourself
fI9hM&index=14
https://www.youtube.com/watch?v=
jYAnbGfWN6g&list=PLZTETldyg
VL - 3 The Do While Loop in Java uF0ZqpdwU3jM_UgHu7- Learn Programming Yourself
fI9hM&index=23
VIVA-VOCEQUESTIONS
I. What is package?
2. Package types? Example?
Experiment No: 3
DevelopajavaapplicationwithEmployeeclasswithEmp_name,Emp_id,Address,Mail_id,Mobile no
as members.Inherit the classes, Programmer, Assistant Professor, AssociateProfessor and Professor
from employee class. Add Basic Pay (BP) as the member of all theinherited classes with 97% of
BP as DA, 10 % of BP as HRA, 12% of BP as PF, 0.1% of BPforstaffclubfund. Generate payslips
forthe employees with theirgross and netsalary.
Aim
To implement Inheritance by developing a java programme with Employee class with Emp_name,
Emp_id, Address, Mail_id, Mobile_no as members. Inherit the classes, Programmer, Assistant
Professor, Associate Professor and Professor from employee class. Add Basic Pay (BP) as the member
of all the inherited classes with 97% of BP as DA, 10 % of BP as HRA, 12% of BP as PF, 0.1% of BP
for staff club fund. Generate pay slips for the employees with their gross and net salary.
.
Algorithm
1. Start the program.
2. Create a class called Employee with Emp_name, Emp_id, Address, Mail_id, Mobile_no as members
and
compute the payslip
3. Extends the Employee class for further classes called Programmer, Assistant Professor, Associate
Professor and Professor
4. Create class called Pay slip and generate Pay slip according to the position of the Employee.
5. Stop the program.
https://www.youtube.com/watc
VL - 2 Parameterized constructor h?v=maIQSChEgoA&t=3s Sundeep SaradhiKanthety
https://www.youtube.com/watc
VL - 3 this() and super keyword h?v=iIvp8Ffa3e4 Sundeep SaradhiKanthety
https://www.youtube.com/watc
Generate Payslip by Inheriting the
VL - 4 h?v=jXRrDcX79Hw&t=2s RK Keynotes
Members from One Class
https://www.youtube.com/watch?v=
VL - 2 Parameterized constructor wjsTWsWpTfY CodeVerse
https://www.youtube.com/watch?v=
VL - 3 this() and super keyword 7d1X0lTWz2U CodeVerse
RESULT
Java program to demonstrate inheritance to the employee class with various type of employee has been
developed to generate the salary slip ofthe employees.
VIVA-VOCEQUESTIONS
Experiment No: 4
Design a Java interface for ADT Stack. Implement this interface using array. Provide necessary
exception handling in both the implementations.
Aim
To implement a Java interface for ADT Stack by implementing this interface using array and to
provide necessary exception handling in both the implementations.
Algorithm
3.Write a java Program to design an interface for Stack ADT. and implement Stack ADT using both
Array and Linked List.
4.Write a Java program for Exception Handling in try-catch statement to handle the exception.
RESULT
Java program to implement an interface for the stack operation has beendeveloped and
tested with sample values to throw an exception.
VIVA-VOCEQUESTIONS
Write a program to perform string operations using Array List. Write functions for the following
a. Append- add at end
b.Insert –add at particular index
c.Search
d.List all string starts with given letter
Aim
Algorithm
https://www.youtube.com/watch?v=
Java Iterator Interface
2 53cFp9P9ao8 Nathan S
https://www.youtube.com/watch?v
3 Scanner class Vignesh Waran
=I17sQfT5MZo
RESULT
Java program to demonstrate string operation using ArrayList has beendeveloped and tested
with sample values.
VIVA-VOCEQUESTIONS
1. What is ArrayList? Advantages?
2. What is append?
Presented in Board of Studies meeting held on --.04.2021(Approved)
Passed in the 1st Academic Council meeting dated --.04.2021
Form No.CD 02 C Rev.No.00 Effective Date: 1/06/2021
VEL TECH HIGH TECH
Dr. RANGARAJAN Dr. SAKUNTHALA ENGINEERING COLLEGE
(An Autonomous Institution, Affiliated to Anna University, Chennai)
R-2021 UG Syllabus for 21BT32T
Experiment No: 6
Write a Java Program to create an abstract class named Shape that contains two integers and an empty
method named print Area(). Provide three classes named Rectangle, Triangle and Circle such that
each one of the classes extends the class Shape. Each one of the classes contains only the method
print Area () that prints the area of the given shape.
Aim
To write a Java Program to create an abstract class named Shape and provide three classes
named Rectangle, Triangle and Circle such that each one of the classes extends the class
Shape.
Algorithm
1. Write a Java program to create an abstract class Bird with abstract methods fly() and make Sound().
Create subclasses Eagle and Hawk that extend the Bird class and implement the respective methods
to describe how each bird flies and makes a sound.
2. Write a Java program to create an abstract class Instrument with abstract methods play() and tune().
Create subclasses for Glockenspiel and Violin that extend the Instrument class and implement the
respective methods to play and tune each instrument.
3. Write a Java program to create an abstract class Employee with abstract methods calculate Salary()
and display Info(). Create subclasses Manager and Programmer that extend the Employee class and
implement the respective methods to calculate salary and display information for each role.
RESULT
Java program to create an abstract class Shape with derived classes Rectangle, Triangle and Circle has
been developed to find the area of different shapes and tested with sample values.
VIVA-VOCEQUESTIONS
4. Why abstract class has constructor even though you cannot create object?
Experiment No: 7
Aim
Algorithm
https://www.youtube.com/w
2. Creating own exceptions atch?v=y01wPwVQqvU SNIPPET_MASTERY
1.Write a Java program that throws an exception and catch it using a try-catch block.
2.Write a Java program to create a method that takes a string as input and throws an exception if the
string does not contain vowels.
RESULT
Java program to implement the user defined exception to check the input value within the given range
has been developed and tested with sample values.
VIVA-VOCEQUESTIONS
Experiment No: 8
Write a Java program that reads a filename from the user, displays information about whether the file
exists, whether the file is readable, or writable, the type of file and the length of the file in bytes.
Aim
To write a Java program that reads a file name from the user, displays information about whether
the file exists, whether the file is readable, or writable, the type of file and the length of the file in bytes.
Algorithm
1. Write a Java program to read a file line by line and store it in a variable.
2. Write a Java program to append text to an existing file.
3. Write a Java program to find the longest word in a text file.
4. Write a Java program to read the contents of a file into a byte array.
RESULT
Java program to know the file information has been developed and tested with sample values.
VIVA-VOCEQUESTIONS
1. What are the different ways of reading a file in Java?
2. How do you read from and write to files using Java code?
3. When should we use serialization? Where is it useful?
4. What is the difference between deep cloning and shallow cloning?
Experiment No: 9
Write a java program that implements a multi-threaded application that has three threads. First thread
generates a random integer every 1 second and if the value is even, second thread computes the square
of the number and prints. If the value is odd, the third thread will print the value of cube of the number.
Aim
Algorithm
1. Start the program
2. Design the first thread that generates a random integer for every 1 second .
3. If the first thread value is even, design the second thread as the square of the number and
then print it.
4.If the first thread value is odd, then third thread will print the value of cube of the number.
5. Stop the program
1. https://www.youtube.com/
Creating MultiThreads watch?v=bWRdvMkaZQ4
Engineer's choice tutor
1. Write a Java program to create a basic Java thread that prints "Hello, World!" when executed.
2. Write a Java program that creates two threads to find and print even and odd numbers from 1 to
20.
3. Write a Java program that creates a bank account with concurrent deposits and withdrawals using
threads.
4. Write a Java program that calculates the sum of all prime numbers up to a given limit using multiple
threads.
RESULT
Java program to implement the multi-threaded application with three threads by generating a
random number and to find the square and cube ofthe number and which is tested with random
numbers.
VIVA-VOCEQUESTIONS
1. What is the thread?
2. Differentiate between process and thread?
3. What is the purpose of wait() method in Java?
4. What are the states in the lifecycle of a Thread?
Experiment No: 10
Write a java program to find the maximum value from the given type of elements using a generic
function.
Aim
To write a java program to find the maximum value from the given type of elements using
a generic function
Algorithm
1. Start the program
2. Define the array with the elements
3. Sets the first value in the array as the current maximum
4. Find the maximum value by comparing each elements of the array
5. Display the maximum value
6. Stop the program
1. Generic https://www.youtube.com/
Programming watch?v=o9YzJN0-AT4
GenericClasses JAVA9S
GenericMethods
1. Write a generic method to exchange the positions of two different elements in an array.
2. Write a generic method to count the number of elements in a collection that have a specific property (for
example, odd integers, prime numbers, palindromes).
RESULT
Java program to implement the generic method to find the maximum among two values has
been developed and tested with different data typevalues
VIVA-VOCEQUESTIONS
1. What is Java Generics?
2. What is the purpose of generics in Java?
3. What is type parameterization in Java?
4. How do you create a generic class in Java?
Experiment No: 11
Design a calculator using event-driven programming paradigm of Java with the following options.
Decimal manipulations Scientific manipulations.
Aim
To design a calculator using event-driven programming paradigm of Java for Decimal manipulations
and Scientific manipulations.
Algorithm
RESULT
Java program for decimal calculator and scientific calculator has been developed and
tested with sample values
VIVA-VOCEQUESTIONS
1. What interface is extended by AWT event listener?
2. What is an event and what are the models available for event handling?
3. What are the advantages of the model over the event inheritance model?
4. What is an adapter class?
Experiment No: 12
Write a java program that perform virtual piano to play music using Jdesign
Aim
Algorithm
1. Create a package for virtual piano application
2. Create a class that extends J frame to implement key lisenter and create an object to read the
event actions
3. Create an Jframe to draw piano and create a jbutton and provide required action
4. Create a method to get key pressed action and input stream to receive data from the Keyboard
5. Create an exception to get audio stream according to the key pressed and continue step 7, 8, 9 to
get different audio stream in different input stream
6. Create another method to get key released action
1. To develop a mini project OPAC system for library using Java concepts.
2. To develop a mini project Bank Mangement system using Java concepts.
RESULT
VIVA-VOCEQUESTIONS
1. How do you define and use variables in Java?
2. What are the different ways to create objects in Java?
3. What’s the difference between an array and an ArrayList?
4. What’s the benefit of using interfaces over abstract classes?
LEARNINGRESOURCES:
TEXTBOOKS:
1. Herbert Schildt, ―Java The complete reference‖, 8th Edition, McGraw Hill
Education,2017.
2. Cay S. Horstmann, Gary cornell, ―Core Java Volume –I Fundamentals‖, 9th Edition,
Prentice Hall, 2017.
3. E.Balagurusamy, Programming with Java, Tata McGill. , Fifth Edition, 20
REFERENCES:
1. Paul Deitel, Harvey Deitel, ―Java SE 8 for programmers‖, 7th Edition, Pearson, 2019.
2. Steven Holzner, ―Java 2 Black book‖, Dreamtech press, 2014.
3. Timothy Budd, ―Understanding Object-oriented programming with Java‖, Updated
Edition, Pearson Education, 2000.