0% found this document useful (0 votes)
174 views

OOPJ Practical List

This lab journal document outlines Madonna Lamin's coursework for Object-Oriented Programming in Java during the academic year 2019-2020 at the Institute of Technology & Management Universe. It contains 6 sets of programming assignments covering key Java concepts like language fundamentals, data types, arrays, classes and objects, strings, and inheritance and interfaces. Each set lists 4-5 programming problems with the proposed and completed dates. The assignments involve writing Java programs to perform tasks like printing strings, adding numbers, calculating areas, analyzing arrays, creating classes for accounts and fans, working with strings, and implementing inheritance.

Uploaded by

sachin kohli
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
174 views

OOPJ Practical List

This lab journal document outlines Madonna Lamin's coursework for Object-Oriented Programming in Java during the academic year 2019-2020 at the Institute of Technology & Management Universe. It contains 6 sets of programming assignments covering key Java concepts like language fundamentals, data types, arrays, classes and objects, strings, and inheritance and interfaces. Each set lists 4-5 programming problems with the proposed and completed dates. The assignments involve writing Java programs to perform tasks like printing strings, adding numbers, calculating areas, analyzing arrays, creating classes for accounts and fans, working with strings, and implementing inheritance.

Uploaded by

sachin kohli
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

LAB JOURNAL

Semester V

Academic Year 2019-20

Object-Oriented Programming in Java

2150704

Madonna Lamin

Department of Computer Science and Engineering

Institute of Technology & Management Universe


Dhanora Tank Road Paldi Village, Halol Highway
Near Jarod, Vadodara District, Gujarat, India 391510
(Approved byAICTE, New Delhi and Affiliated to Gujarat Technological University)
June 2019
SET 1 – Language Fundamentals

Practical List
SNo. Program Proposed Completed Remarks
Date Date
1 Write a Java program to print the string 28.06.2019
literal “Hello World!!!”

2 Write a Java program to print the poem 28.06.2019


“Mary had a little lamb
Its fleece was white as snow
Everywhere that Mary went
The Lamb was sure to go”

3 Write a Java program to add two numbers 28.06.2019


using Command Line
Argument

4 Write a Java program to convert rupees 5.7.2019


into dollars using
(i) Command Line
Argument
(ii) Scanner Class
SET 2- Data Types and Operators
SNo. Program Proposed Completed Remarks
Date Date
1 Write a Java program to compute the area 12.7.2019
of a circle using Scanner class

2 Write a Java program that calculates the 12.7.2019


percentage marks of the student if marks
of 6 subjects are given.

3 Write a program to enter two numbers 19.7.2019


and perform mathematical operations on
them.

4 Write a Java program that converts a 19.7.2019


Fahrenheit degree to Celsius using the
formula: Celsius = (5/9) (Fahrenheit - 32)

5 Write a program that computes loan 19.7.2019


payments. The loan can be a car loan, a
student loan, or a home mortgage loan.
Allow the user to enter the interest, rate,
number of years and loan amount, and
display the monthly payment as follows:
SET 3 - Arrays
SNo. Program Proposed Completed Remarks
Date Date
1 Counting occurrence of numbers. Write a 26.7.2019
program that reads the integers between 1
and 100 and counts the occurrences of each.
Assume the input ends with 0
Sample Run:
Enter the integers between 1 and 100:2 5 6 5
4 3 23 43 2 0
2 occurs 2 times
3 occurs 1 time
4 occurs 1 time
5 occurs 2 times
6 occurs 1 time
23 occurs 1 time
43 occurs 1 time

2 (Analyzing scores). Write a program that 26.7.2019


reads an unspecified number of scores and
determines how many scores are above or
equal to the average and how many scores
are below the average. Enter a negative
number to signify the end of the input.
Assume that the maximum number of scores
is 10.

3 (Eliminating Duplicates).Write a method to 2.8.2019


eliminate the duplicate values in the array
using the following method header
public static int[] eliminateDuplicates(int[]
numbers)

4 Computing weekly hours for each 2.8.2019


employee). Suppose the weekly hours for all
employees are stored in a two-dimensional
array. Each row records an employee’s
seven-day work hours with seven columns.
For example, the array shown below stores
the work hours for eight employees. Write a
program that displays employees and their
total hours in decreasing order of the total
hours.
5 (Locating the largest element). Write the 9.8.2019
following method that returns the location of
the largest element in a two-dimensional
array.
public static int[] locateLargest(double[][]a)
The return value is a one-dimensional array
that contains two elements. These two
elements indicate the row and column
indices of the largest element in the two
dimensional array. Write a test program that
prompts the user to enter a two-dimensional
array and displays the location of the largest
element in the array. Here is a sample run:
SET 4-Classes and Objects
SNo. Program Proposed Completed Remarks
Date Date
1 Account Class 16.8.2019
2 Fan Class 16.8.2019
(a) (The Account class) Design a class named Account that contains:
■ A private int data field named id for the account (default 0).
■ A private double data field named balance for the account (default 0).
■ A private double data field named annualInterestRate that stores the
current
interest rate (default 0). Assume all accounts have the same interest rate.
■ A private Date data field named dateCreated that stores the date when
the account was created.
■ A no-arg constructor that creates a default account.
■ A constructor that creates an account with the specified id and initial
balance.
■ The accessor and mutator methods for id, balance, and
annualInterestRate.
■ The accessor method for dateCreated.
■ A method named getMonthlyInterestRate() that returns the monthly
interest rate.
■ A method named withdraw that withdraws a specified amount from the
account.
■ A method named deposit that deposits a specified amount to the account.
Draw the UML diagram for the class. Implement the class. Write a test program
that creates an Account object with an account ID of 1122, a balance of
$20,000, and an annual interest rate of 4.5%. Use the withdraw method to
withdraw $2,500, use the deposit method to deposit $3,000, and print the
balance, the monthly interest, and the date when this account was created.

(b) (The Fan class) Design a class named Fan to represent a fan. The class
contains:
■ Three constants named SLOW, MEDIUM, and FAST with values 1, 2,
and 3 to denote the fan speed.
■ A private int data field named speed that specifies the speed of the fan
(default SLOW).
■ A private boolean data field named on that specifies whether the fan is on
(default false).
■ A private double data field named radius that specifies the radius of the
fan (default 5).
■ A string data field named color that specifies the color of the fan (default
blue).
■ The accessor and mutator methods for all four data fields.
■ A no-arg constructor that creates a default fan.
■ A method named toString() that returns a string description for the fan. If
the fan is on, the method returns the fan speed, color, and radius in one
combined string. If the fan is not on, the method returns fan color and radius
along with the string “fan is off” in one combined string.

Draw the UML diagram for the class. Implement the class. Write a test
program that creates two Fan objects. Assign maximum speed, radius 10,
color yellow, and turn it on to the first object. Assign medium speed, radius
5, color blue, and turn it off to the second object. Display the objects by
invoking their toString method.
SET 5-Strings
SNo. Program Proposed Completed Remarks
Date Date
1 (Counting Each Letter in a String). Write a 23.8.2019
program that prompts the user to enter a
string and counts the number of
occurrences of each letter in the string
regardless of case.

2 (Anagrams). Write a method that checks 23.8.2019


whether two words are anagrams. Two
words are anagrams if they contain the
same letters in any order. For example,
“silent” and “listen” are anagrams. The
header of the method is as follows:
public static Boolean
isAnagram(String s1, String
s2)
Write a test program that prompts the user
to enter two strings and, if they are
anagrams, displays “anagram”, otherwise
displays “not anagram”
3 (Palindrome). Write a program that 30.8.2019
prompts the user to enter a string and
reports whether the string is a palindrome.

4 (Checking substrings). You can check 30.8.2019


whether a string is a substring of another
string by using the indexOf method in the
String class. Write your own method for
this function. Write a program that prompts
the user to enter two strings, and check
whether the first string is a substring of the
second.

5 (Sorting characters). Write a method that 30.8.2019


returns a sorted string using the following
header:
public static String sort(String s);
For example, sort(“acb”) returns abc
Write a test program that prompts the user
to enter a string and displays the sorted
string.
SET 6-Inheritance and Interface
SNo. Program Proposed Completed Remarks
Date Date
1 Describe abstract class called Shape which 6.9.2019
has three subclasses say
Triangle,Rectangle,Circle. Define one
method area() in the abstract class and
override this area() in these three
subclasses to calculate for specific object
i.e. area() of Triangle subclass should
calculate area of triangle etc. Same for
Rectangle and Circle.
2 Write a program that illustrates interface 6.9.2019
inheritance. Interface P is extended by P1
and P2. Interface P12 inherits from both P1
and P2.Each interface declares one
constant and one method. class Q
implements P12.Instantiate Q and invoke
each of its methods. Each method displays
one of the constants

3 The abstract Vegetable class has three 13.9.2019


subclasses named Potato, Brinjal and
Tomato. Write an application that
demonstrates how to establish this class
hierarchy. Declare one instance variable of
type String that indicates the color of a
vegetable. Create and display instances of
these objects. Override the toString()
method of Object to return a string with the
name of the vegetable and its color.
Declare an abstract method howToEat() to
display how the vegetables are to be
prepared.
4 The Transport interface declares a deliver() 13.9.2019
method. The abstract class Animal is the
superclass of the Tiger, Camel, Deer and
Donkey classes. The Transport interface is
implemented by the Camel and Donkey
classes. Write a test program that initialize
an array of four Animal objects. If the
object implements the Transport interface,
the deliver() method is invoked.
SET 7-Exception Handling
SNo. Program Proposed Completed Remarks
Date Date
1 Write a program to handle 20.9.2019
NoSuchMethodException,
ArrayIndexOutOfBoundsException using
try-catch-finally and throw.

2 Write an application that generates custom 20.9.2019


exception if any value from its command
line arguments is negative.

3 Write a method for computing x y by doing 20.9.2019


repetitive multiplication. x and y are of
type integer and are to be given as
command line arguments. Raise and handle
exception(s) for invalid values of x and y.
Also define method main. Use finally in
above program and explain its usage.
SET 8-I/O
SNo. Program Proposed Completed Remarks
Date Date
1 Create a class Student. Write a 27.9.2019
student manager program to
manipulate the student information
from files by using FileInputStream
and FileOutputStream.

SET 9-MultiThreading
SNo. Program Proposed Completed Remarks
Date Date
1 Write an application that creates and 4.10.2019
starts three threads. Each thread is
instantiated from the same class. It
executes a loop with 10 iterations.
Each iteration displays string
"HELLO", sleeps for 300
milliseconds. The application waits
for all the threads to complete &
displays the message "Good Bye...".
SET 10- UML DIAGRAMS

1. Prepare a class diagram for given group of classes using multiplicity,


generalization, association concepts. And add at least 5-7 attributes and 3-5
operations for particular class

Page, Shape, Point,Line, Arc, Ellipse, Rectangle, Circle

2. Prepare a class diagram for given group of cl asses using multiplicity,


generalization, association concepts. And add at least 5-7 attributes and 3-5
operations for particular class.

City,Airport, Airline, Pilot, Flight, Plane, Seat, Passenger

3.Categorize the following relationships into generalization, aggregation or


association.

[A] A country has a capital city

[B] A dining philosopher uses a fork

[C] A file is an ordinary file or a directory file

[D] Files contains records

[E] A polygon is composed of an ordered set of points

[F] A drawin

g object is text, a geometrical object, or a group

[G] A person uses a computer language on a object

[H] Modems and keyboards are input/output devices

[I] Classes may have several attributes

[J] A person plays for a team in a certain year


[K] A route connects two cities

[L] A student takes a course from a professor

4. Prepare a state diagram for an interactive diagram editor for selecting and
dragging objects

5. Prepare a use case diagram and sequence diagram for a computer email
system

6.Prepare an activity diagram for computing a restaurant bill, there should be


charge for each

delivered item. The total amount should be subject to tax and service charge
of 18% for group of six and more. For smaller groups there should be a
blank entry. Any coupons or gift certificatessubmitted by the customer
should be subtracted

7.Prepare a sequence diagram for issuing a book in the library management


system

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy