Sie sind auf Seite 1von 16

JAVA PROGRAMMING

ASSIGNMENT - 2004 Batch

Java Programming Language

Note: 1. Solve any 10 programmes


2. Each Programme carries 10 marks
3. The weight of these programmes is 40% (other 60% is for Online assignment
submission)

Q. 1. Write a program that converts a decimal number to Roman number. Decimal


Number is accepted as command line input at the time of execution

Q. 2. Write a program that prints prime numbers between 1 to n. Number n should be


accepted as command line input.

Q. 3. Write a program that prints first n Fibonacci numbers. Number n should be


accepted as command line input. Any Fibonacci number is calculated as, sum of its
previous 2 numbers,

e.g. 0 , 1 , 1 , 2, 3 , 5 , 8 , 13 , …………..

First 2 Fibonacci numbers are 0 and 1.

Q. 4. Write a program to print out multiplication tables from 9 to 17 using (I) for
loops (II) while loops (III) do loops.

Q. 5. Write a program to print the following triangle of numbers.

1 2

1 2 3

1 2 3 4

1 2 3 4 5

Q. 6. Write a program to convert Fahrenheit temperature to the Centigrade equivalent.


Fahrenheit temperature should be accepted from the user.

Centigrade = (Fahrenheit – 32) * 5.0/9.0

Q . 7. Define a class called Circle with the attributes radius, circumference, and area of
the circle. Write a program to display all attributes of the circle for 5 Circles. Radius for
all 5 circles should be accepted as command line input at the beginning. e.g. java
Circlejava 5 10 12 25 36

Q . 8. Write a program to find the Factorial of a number using Recursion. Factorial can
be defined as Factorial(n) = 1 * 2 * 3 ….* (n-1) * n.

Q . 9. Write a program to get the input values Principal, rate of interest and number of
Years from the keyboard and find the simple interest.

Q. 10. Write a program to create an applet with yellow back ground and display the
Message WELCOME TO THE JAVA WORLD. Write its HTML document also.

Q. 11. Write a java program to create a Frame with three buttons Morning, Afternoon
and Evening. When we click Morning button, the message “Good Morning to you” must
be displayed. Similar messages must be displayed for the other buttons also.

Q. 12. Write a Java program to create a List box with some colors in the items. When
the color is selected, the background color must change accordingly. Write a program
which creates and displays the details in the List box on the window.

Q13. Write a program to show demonstration of CardLayout and Flowlayout. Create 2


panel, Top & Main. Top panel contains 3 buttons Button 1 , Button 2 & Button 3 in
Flowlayout. Main panel contains 3 panels First Panel, Second Panel and Third Panel. On
selection of any panel display appropriate message. Here Applet is to be used by
implementing ActionListener.

Q . 14. Write a Java program to create a Frame which responds to the mouse click. For
each event with mouse ( such as mouse up, mouse down etc.) the corresponding message
must be displayed.

Q . 15 . Write a program to explain the multithreading with the use of multiplication


tables. Three threads must be defined. Each one must create one multiplication table,
they are 5 table, 7 table and 13 table. And assign priority 1 to 5 Table, priority 5 to 7
Table and priority 8 to 13 Table. And then run the threads.

Q . 16 . Write a Java program to create simple Calculator for 4 basic Math operations,
Addition, Subtraction, Multiplication and Division. In the window there are four
radio buttons called Add, Sub, Mul and Div at the Top. This group is called Operation.
There are two textfield objects to input first and second number.We must type the
numbers and select one of the operations. When we click the perform button, the result is
displayed. For example if the first number is 10 and second number is 72 And operation
selected is Mul then the result is displayed as,

The result is 720.


Practice

Sample Examination Questions

• A palindrome is a number that reads the same forward and backward.


Examples are 12344321 , 5689865 etc.
Write a program that reads a number ( upto 8 digits) and checks whether it is a
palindrome number or not.

• Write a method to calculate next date of the given date.


Date should be accepted from the user.

• Write a program that detects successive repeated occurrence of a letter in a


word. For example, how many occurrences of the letter m, t and e are there in
the word committee.
Students must attempt Total 2 projects.

On project from 1A OR 1B. And One more Project from 2A OR 2B.

All Projects carry equal marks i.e 50

/* Project Question No. 1A:

Create a class ToyCollection that stores information about different toys in a toy shop.
The information to be stored about a single toy is,

- Toy identification as String


- Name of the toy as String
- Short description about the toy as a String
- Price of the toy as float
- Quantity of the toy in hand as short integer.

This class contains following methods,

- Constructor method that assigns user input values to above mentioned


variables.

- main ( ) method that creates array of 4 objects of ToyCollection class


and that takes input for all above details from the user and
calls method to check validity of Quantity and Price values. If all values
are valid then create the objects and display the details
for all 4 toys.
- Method that checks validity of quantity and price. If the quantity is 0 or
negative then method should throw user defined
exception with appropriate message and come out of program. Similarly
if the price is 0 or negative then it should throw user defined exception
with appropriate message and come out of program.

- Method that displays all details about a single toy in the following
format, e.g. Here Total price should be calculated.

Toy Identification : S-1


Toy Name : Small Scooter
Toy Description : Ordinary 3 wheeler scooter
Toy price : 650.50
Quantity in hand : 3
Total price of Toys : 1951.50

*/ End of Question no. 1A


Project Question No. 1B : [ This Question is OR to Question no. 1A]

A small scale private company has 2 categories of employees, i.e. Regular and Daily
wages type. This program should accept information from the user, about 3 regular
Employees and 3 Daily category employees and store this data in a display of objects.

At the end this program should ask the user to enter the employee id number and should
find out whether the particular employee is present or not. If the employee is present
then his monthly salary and other information should be displayed in the following
manner,

Employee Identification : 101

Employee Name : Ramesh B. Jadhav

Employee Address : 501, Sadashiv Peth, Pune 411 30.

Employee Category : Regular

Monthly Salary : Rs.10,500.00

If the employee is not found then proper error message should be displayed and stop the
program.

In this program student is expected to create 4 classes as described below.

1. Emp Class : This is an abstract class. It contains following information,

- Employee identification number an integer number, This is


automatically generated starting from 101.
- Employee category which is of character type and can have
only 2 values R or D. R for regular type and D for daily
wages type
- Employee name of String type.
- Employee Address of String type.

This class has following methods,

- Constructor method to initialize all 4 variables given above


- One method that displays all above information in required
output format.
- One abstract method defined as, float calculate Salary ( ) ;
This method is overridden in the two subclasses.

2. regularEmp class : This is one subclass of above defined Emp class and
stores following information,
- Basic salary as float
- Allowance as float
- Deductions as float

This class contains following methods,

- Constructor.
- Overridden method calculate Salary to calculate and
return monthly salary.
Method that displays the data in this class and super
class in the required output format.

3. dailyEmp class : This is one subclass of above defined Emp class and
stores following information

- Daily work Rate as float


- Number of days worked in the month as integer. This
class contains following methods,
- Constructor
- Overridden method calculate Salary to calculate and
return monthly salary
- Method that displays the data in this class and super
class in the required output format.

4. Salary class : This class contains following information,

- Array of three objects of regularEmp class and


- Array of three objects of daily Emp class
- 2 counts as indices of these arrays.
- And other required variables related to other classes.

This class contains following methods,

- main method, that accepts data for 3 regular


employees and 3 daily
category employees and stores in the array of
objects
Category of the employee should be accepted only as
R or D.
Calls the method to check the employee Id.

- method that accepts employee id as input parameter


and returns Boolean value. This method checks
whether the employee is present in any of the two
arrays or not. If yes then displays all his information
in the required output format otherwise returns false.
End of Question no. 1B

Project Question No. 2A

A Scroll Banner is an applet which displays 2 scrolling messages across the


applet’s Window. Since the scrolling of a message is a repetitive task, it is
performed by a Separate thread, created by the applet when it is initialized. Here
background color used for the applet is yellow and foreground color used for
displaying the messages is red. The upper message is displayed at position x =
100 and y = 200. This message is scrolled from right to left. The lower message
is displayed at position x = 100 and y = 50. This message is scrolled from left to
right. The Browser displays the applet till new page comes into view. At this time
the Applet stops itself.

End of Question 2A.

OR

Project Question No. 2B :

Create 2 Thread classes.One Thread is Incrementor and has one variable cnt1
with initial Value 0. Incrementor thread increments value of cnt1 by 1 each
time. The other thread is Decrementor which has variable cnt2 with initial value
100. Decrementor thread decrements value of cnt2 by 1 each time.

- Incrementor thread increments value of cnt1 by one and notifies the other thread
about this value

- The decrementor thread decrements value of its variable cnt2 by one and
compares values of cnt1 and cnt2. If values of cnt1 and cnt2 are different then
notifies the Incrementor thread and above mentioned step is repeated.

- But if values of cnt1 and cnt2 are matching then following message is displayed

Matching Value : 50

- Now Decrementor thread sets a flag as true and notifies the other thread and stops its
execution.

- As flag is set to true, Incrementor thread understands that matching has occurred and
stops its execution

NOTE : In this example use of wait ( ) , notify ( ) and synchronize statements is


expected.

End of Question 2B
WEB TECHNOLOGY
HTML Practical Programs

Note: 1. Each question carries 10 marks.


2. Distribution of marks is given at each question.

Q. 1 Create an HTML page as below: ( 5 marks for HTML, 5 marks for code.)
The HTML page uses an HTML FORM having two input fields to accept username
and password. Validate using Javascript that no field is empty
Q. 2 Create an HTML page to accept any number. Check whether the number is prime or
not. ( 3 marks for HTML, 7 marks for code.)

Q. 3 Create a form as follows. When user clicks on ‘submit’ button display the entered /
selected options in a new window.
2 marks
Name :

Address 2: marks

Gender : Male Female

Education :
2 marks

Submit
Submit

Q. 4 Write a HTML page to insert two images, one with border and the other without
border. (4 marks) The image without border should provide links to three different html
files. (6 marks)

Q. 5 Create a form for the following ( design – 5 marks, coding – 5 marks)

Name : 2 marks

Subjects : C Prog Java Prog.

Visual Basic MIS


Use List Box
State :
Q. 6 Create a dynamic page using CSS as follows.
The text displayed using <H1> should have background color ‘blue’ and text color
‘white’. (2 marks)
The paragraph can be displayed in two formats:
Background color ‘sky blue’, text color ‘dark blue’, font ‘verdana’ and font size ‘4’ (4
marks)
Background color ‘pink’, text color ‘brown’, font ‘times new roman’ and font size ‘3’ (4
marks)

Q. 7 Create the following page using frames.

1.. Educational Qualification

2. Project Experience Welcome to


3. Computer Literacy

4.My Speciality
My Profile
Display the relevant information in the 2nd frame on selection of a link. There
should be a link to return to home page - ‘Welcome to My Profile’ in each linked
page.
Marks Distribution:
Frame Page : 1 mark, Welcome Page – 1 mark,
Link Page to be displayed in 1st frame : 4 marks
Linked pages to be displayed in 2nd frame : 4 marks

Q. 8 Write a JavaScript code for the following:


a) Provide a combo box which will allow to provide image names. On selecting a
particular image name display the relevant image in the new window. Write a
code using function. (5 marks)
b) Provide 3 check boxes for the subjects. For each subject provide the radio buttons
to select Optional / Compulsory. When user clicks on “Display” button, show the
selected contents in table. In first column display the subject name and in the next
column display Optional / Compulsory. (5 marks)

Q. 9 Write a code to accept the 10 numbers in array. Provide the buttons for displaying
the array contents in random order, ascending order, descending order, sum of all
numbers.
Marks distribution :
Accept numbers : 2 marks, Random Order : 2 marks, Ascending Order : 2 marks,
Descending Order : 2 marks, Sum of the numbers : 2 marks
Q. 10 Write HTML code for the following:
a) (5 marks)
A B C D E
F G H
I J K L M
N O P Q R
S T U
b) (5 marks)
Create two vertical frames where first frame will be ¼ size of the screen. In first
frame display the links for 4 courses like MCM, MBA, PGDBM and MPM.
When user clicks on particular link display relevant six subjects in the second
frame. First Frame should have the background color “blue”. Second frame
should have background color “sky blue”.

Q. 11 Using Java script create an array of 10 elements. Accept values from user. Store
accepted values in list box.

Q. 12 Using Java script accept any number. Display the sum of all digits and the number
in reverse order.

Q. 13 Display all prime numbers between 1 and 100 in text area.

Q. 14 Accept any number in text box. Display its prime factors.

Q. 15 Accept string from the user. Display its length and no. of words in the string.

Q. 16 Accept two different strings from the user. Write a java script to check whether
second string exists in first string or not.

HTML Exam Programs

Note : 1. Each question carries 50 marks.

Q. 1 Design an HTML page to accept any two numbers and do the following: (5 marks)
a) Provide the operator buttons to perform the arithmetic operations i.e. add, subtract,
multiplication and division. Display the answer in new page. (Write functions) (20
marks)
For No 1 → b) Display the lucky number in another text box on clicking a given
button. (E.g. if number entered is 272 then its lucky no. is 2 + 7 + 2 = 11 = 1 + 1 = 2.
Thus 2 is the lucky number of 272) (15 marks)
For No 2 → c) Display the accepted number in reverse order on clicking a given
button in new window. (10 marks)

OR

Q. 1 Design an HTML page to accept any string and do the following by providing
command buttons: (5 marks)
a. Display length of the string (5 marks)
b. Display each character on a new line (10 marks)
c. Replace all blank spaces with “#” symbol. (10 marks)
d. Accept a character from the user and display the occurrence of the same in a
string. (10 marks)
e. Display no. of words in a string. (10 marks)

Q. 2 Create an order form using HTML tags for purchasing books. The order form should
contain Publisher Name, Author names, Book Title, Price, Edition, Vendor Name,
Quantity. Calculate the bill amount considering Tax 4% and discount as follows:
a. if amount >=50000 15%
b. if amount >=25000 and <50000 10%
c. if amount >=15000 and <25000 5%
d. if amount<15000 Nil.
(25 marks for HTML Design. 25 marks for bill amount calculation.)
Note : Do required validations.

OR

Q. 2 Design a Registration form for new email account. Validate the inputs. Display all
entered contents on new page.

C programming

Section 1:

Q.1 Write a C Program to display following menu


Menu
1. Display
2. Copy
3. Append
4. Exit
Accept the choice (1-4) from the user, and perform following tasks:
Choice 1: Accept a file name from the user and display the file on screen
Choice 2: Accept two file names, and copy first file to the second
Choice 3: Accept two file names, and append second file to the first file
Choice 4: Terminate the program

Your program should have appropriate validations

Marks:50

(OR)

Write a C Program to create a structured data file named Student.dat to store the roll
no, name and course.
Provide following functions:
1. Accept the values from the user using structure variables. Store the contents
in a file.
2. Display the file.
3. The user should be able to add new records to the existing file. And display
the new file.

Marks: 50

Section 2 :

Q.2 Write a C Program to declare an array for 2 0 floats. Accept the values from
the user sort the two arrays in descending order. Merge the two arrays into a
new array and display the new array.

Marks: 50

(OR)

Accept any two numbers from the user. Perform the following operations on it using
functions:

1. Addition
2. Subtraction
3. Multiplication
4. Swap the values
5. Print both the numbers in reverse order for example (if a given number is
234, it should be printed as 432)

Marks:50
SAMPLE EXAMINATION PROJECTS for Practice (50 marks each)

1. Following is the menu to be displayed to the user on selecting a choice display


the appropriate result. Number should be accepted from the user.

Menu

1. Odd / Even Number


2. Prime Number
3. Divisible by 100
4. Factorial Number

2. Perform the following operations on integer array of io elements:

1. Accept the values from user and display the same.


2. Sort an array in descending order.
3. Display sum of all the elements
4. Replace all l by 0

3. Write a program for the following:

1. Read the contents of the text file.


2. Display no. of characters in the file.
3. Display no. of words in the file.
4. Write contents to the file without overwriting the previous contents.

Please note that the project will be evaluated on the following criteria:-

1. Documentation of the code


2. Desired Result
3. Presentation

ASSIGNMENT - 2004 Batch


C Programming Language.

Note:
1. Solve any 10 programmes.
2. Each programme carries 10 marks.
3. The weightage of these programmes is 40% (other 60% is for online
assignment
submission).
Q. 1 Calculate area and perimeter of a rectangle and a circle. Accept
concern parameters
from the user.
[ 1, Let Us C by Mr. Yashavant Kanetkar]
Q. 2 If a six digit number is input through the keyboard i.e. accept from
the user, display
a number in reverse order.
[ I, Let Us C by Mr. Yashavant Kanetkar]
Q. 3 Any 3 numbers is input through the keyboard. Display maximum
and minimum
number.
[ 2, Let Us C by Mr. Yashavant Kanetkar]
Q. 4 Any number is input through the keyboard. Display whether the
number is odd or
even.
[ 2, Let Us C by Mr. Yashavant Kanetkarl
Q. 5 Display all prime numbers between 1 and 500.
[ 3, Let Us C by Mr. Yashavant Kanetkar]
Q. 6 Any 5 digit number is inpUtthrough the keyboard. Display the
number in words. e.g
if number entered is 23435, output should be Two Three Four Three
Five.
[ 3 and 4, Let Us C by Mr. Yashavant Kanetkar]
Q. 7 Write a programme to display addition and multiplication of two
numbers. Add and
Multi are the functions to be called to perform the operation. Function
Add should not
return any value.
[ 5, Let Us C by Mr. Yashavant Kanetkar]
Q. 8 Write a function prime(int) to return whether a number is prime ot
not. [ 5, Let Us C
by Mr. Yashavant Kanetkar]
Q. 9 Create an integer array of 10 elements and accept the values from
the user. Display
array in descending order.
[ 8, Let Us C by Mr. Yashavant Kanetkar]
©Symbiosis Centre for Distance Learning
Q. 10 Create an integer array of 5 elements and accept the values from
the user. Display
sum of all elements.
[ 8, Let Us C by Mr. Yashavant Kanetkar]
Q. 11 Create an integer array of 5 elements and accept the values from
the user. Display
sum of all elements.
[ 8, Let Us C by Mr. Yashavant Kanetkar]
Q. 12 Declare a character array of 25 elements and accept any string
from the user.
Display length of a string with using strien function. Also replace all s
with r’.
[ 9, Let Us C by Mr. Yashavant Kanetkar]
Q. 13 Declare a character array of 50 elements and accept any string
from the user. Copy
this string to another array using pointer. (Do not use strcpy function.)
[ 9, Let Us C by Mr. Yashavant Kanetkar]
Q. 14 Create a structure for student containing roll no., name, city and
course. Write a
programme to accept and display the values using structure.
[ 10, Let Us C by Mr. Yashavant Kanetkar]
Q. 15 Write a programme to count the number of words and characters
in a given text
file.
[ I Let Us C by Mr. Yashavant Kanetkar]
Q. 16 Write a programme to display the contents of a given text file.
Also write a code to
append the contents to the given text file.
[ ii, Let Us C by Mr. Yashavant Kanetkar]
©Symbiosis Centre for Distance Learning

Das könnte Ihnen auch gefallen