ACADEMIC YEAR 2020-2021 [ODD SEMESTER]
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Faculty Name : Dr.K.Kartheeban Year /Sec: II/ B
Subject Name with Code : Java Programming / CSE18R272 Unit: I, II, III, IV, V
Assignment
1. Consider an automobile industry consist of many departments and each department
there are many employees working in it. Based on the qualification of each
employees, their salary will be calculated based on their basic pay and other
allowances. Develop a java based program with class Employee and do the following
operations on it. (a). Create two constructor default and with Object as parameter to
initialize class variables.(b).Create a function calculate which calculates the pf and
allowances on the salary of employee and return the all values as an object. (c).Print
all the employee object associated values returned from calculate functions.
2. A word-ladder puzzle is one in which you try to connect two given words using a
sequence of English words such that each word differs from the previous word in the
list only in one letter position. For example, the figure at the bottom shows a word
ladder that turns the word TEST into the word OVER using eight single-letter steps .
In this problem, your job is to write a program that checks the correctness of a word
ladder entered by the user. Your program should read in a sequence of words and
make sure that each word in the sequence follows the rules for word ladders, which
means that each line entered by the user must
A. Be a legitimate English word
B. Have the same number of characters as the preceding word
C. Differ from its predecessor in exactly one character position
Implementing the first condition requires that you have some sort of dictionary
available, which is well beyond the scope of this problem. You may therefore assume
the existence of a Lexicon class (generally speaking, a lexicon is simply a list of
words) that exports the following method:
public boolean isEnglishWord(String str)
which takes a word (String) and returns true if that word is in the lexicon (i.e., the
string passed is a valid English word). You may also assume that you have access to
such a dictionary via the following instance variable
declaration: private Lexicon lexicon = new Lexicon("english.dat");
All words in the lexicon are in upper case.
If the user enters a word that is not legal in the word ladder, your program should
print out a message to that effect and let the user enter another word. It should stop
reading words when the user enters a blank line. Thus, your program should be able to
duplicate the following sample run that appears on the next page (the italicized
messages don’t appear but are there to explain what’s happening).
3. Write a GraphicsProgram that does the following: 1. Add buttons to the South region
labeled "North", "South", "East", and "West". 2. Create an X-shaped cross 10 pixels
wide and 10 pixels high. 3. Adds the cross so that its center is at the center of the
graphics canvas. Once you have completed these steps, the display should look like
this:
Implement the actions for the button so that clicking on any of these buttons moves
the cross 20 pixels in the specified direction. At the same time, your code should add
a red GLine that connects the old and new locations of the pen.
Keep in mind that each button click adds a new GLine that starts where the previous
one left off. The result is therefore a line that charts the path of the cross as it moves
in response to the buttons. For example, if you clicked East, North, West, North, and
East in that order, the screen would show a Stanford “S” like this (note the "S" would
be red, even though it does not appear so in the black and white handout):
4. The libraries of KARE-CSE need a new electronic rental system, and it is up to you to
build it. Students of this CSE department may prepare to take book to their rooms for
preparing. KARE CSE has two libraries. Each library offers many books to rent.
Customers can print the list of available books, borrow, and return books. We provide
two classes, Book and Library that provide the functionality for the book database.
First we need a class to model books. Start by creating a class called Book. This class
defines methods to get the title of a book, find out if it is available, borrow the book,
and return the book. And create a class called Library. We provide a main method that
creates two libraries, then performs some operations on the books. However, all the
methods and member variables are missing. You will need to define and implement
the missing methods. Read the main method and look at the compile errors to figure
out what methods are missing Develop a java based program to implement the
missing methods and to make these classes work to perform libraries functions.
5. In the last several years, a new logical puzzle from Japan called Sudoku has become
quite a hit in Europe and the United States. In Sudoku, you start with a 9 x9 grid of
numbers in which some of the cells have been filled in with digits between 1 and 9, as
shown in the upper right diagram. Your job in the puzzle is to fill in each of the empty
spaces with a digit between 1 and 9 so that each digit appears exactly once in each
row, each column, and each of the smaller 3x3 squares. Each Sudoku puzzle is
carefully constructed so that there is only one solution.
Suppose that you wanted to write a program to check whether a proposed solution
was in fact correct. Because that task is too hard for an array problem on an exam,
your job here is simply to check whether the upper-left 3x3 square contains each of
the digits 1 through 9. In the completed example (shown in the bottom right diagram),
the 3x3 square in the upper left contains exactly one instance of each digit and is
therefore legal.