Sie sind auf Seite 1von 2

Assignment Project work

Java Programming Language

Note: 1. Solve any 10 programs'


2. Each Program carries 10 marks
3. Source Code should be send in .txt file
4. Output / Screen Shot should be sent in .jpeg file
5. Please send assignment project on pgdit3@scdl.net, in soft copy only.
6. No Hard Copy of the assignment project will be accepted.

Q.1 Write a Java program that calculates and prints the simple interest using the formula :
Simple Interest = PNR / 100
Input values P,N,R should be accepted as command line input as below.
e.g. java Simple Interest 5 10 15
Q.2 Write a program to compute sum of digits of a given number.
(Hint: Separate digits one by one from the number and then add)
Q.3 The numbers in the following sequence are called the Fibonacci numbers.
0, 1, 1, 2, 3, 5, 8, 13, …………..
Write a program using do…..while loop to calculate and print the first m Fibonacci
numbers.
(Hint: After the first two numbers in the series, each number is the sum of preceding
two numbers.)
Q.4 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.5 Write a program that prints prime numbers between 1 to n. Number n should be
accepted as command line input.
Q.6 Write a program to print the following output using the for loop.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Q.7 Write a Java program that accepts the radius of a circle and displays the options as
follows :
1. find diameter of a cicle.(2* radius)
2. find area of circle.( Π * radius * radius)
3. find circumference of a circle.( 2 * Π * radius)
4. Exit.
Use case statement to implement each option and display the corresponding
output.
Q.8 Define a class called fruit with the following attributes :
1. Name of the fruit.
2. Single fruit or bunch fruit.
3. Price.
Define a suitable constructor and display Fruit () method that displays values of all
the attributes. Write a program that creates 2 objects of fruit class and display their
attributes.
Q.9 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.10 Write a class vehicle .Define suitable attributes and methods. Write subclasses of
Vehicle like Car, Bicycle, and Scooter. Assume suitable required attributes. Write
constructor for each and define a method maxSpeed() in each class which prints the
maximum speed of the vehicle.
(use of super keyword is expected in the constructor of inherited classes)
Q.11 Define an exception called “NoMatchException” that is thrown when a string is not
equal to “Symbiosis”. Write a Java program that uses this exception.
Q.12 Write a program that demonstrates the use of multithreading with the use of three
counters with three threads defined for each. Three threads should represent the
counters as follows :
1) One counter starts from 5 and increments with the step of 5.
2) Second counter starts from 10 and increments with the step of 10.
3) Third counter starts with 100 and increments with the step of 100.
Assign proper priority to the threads and then run the threads.
Q.13 Write a program to create an applet with red back ground and display the
Message WELCOME TO THE WORLD OF APPLETS. Write its HTML document
also. Specify width and height to the Applet.
Q.14 Write a program that detects successive repeated occurrence of a letter in a word. For
example, in the word “explanation” letter ‘a’ and ‘n’ occurs twice.
Q.15 Write a Java program to create an JApplet with three Jbuttons Morning, Afternoon
and Evening. When we click Morning button, the message “Good Morning to you”
must appear. Similar for the other two buttons “Good Afternoon to you” and “Good
evening to you” must appear. Each message must appear in a different Background,
text, Color and Font.
Q.16 Write a program to demonstrate use of Grid Layout. On a frame with grid layout place
buttons labeled respectively with the letters from ‘A to Z’. For example if you click
the button labeled Z the message “You have clicked the Z “button should appear.
(Set suitable number of rows and columns).

You are required to send the following to SCDL, along with the question paper:
1. Print out the code.
2. Print of the output.
***************************************************************************
Sample Examination Questions For Practice Purpose ( not to be submitted )

• Write a Java program that displays the reverse of a given number.

• Write a program that calculates the length (i.e. number of characters) in the input
string.

• Write a Java program to create a JFrame that displays a letter ‘A’ and which responds
to the mouse click. For each mouse click it increases the size of the letter.

• Create a class Date Printer with a method to print today’s date . Use this method from
class Util, first by creating an instance of class DatePrinter and next by using an
anonymous class that extends class DatePrinter. Override the print Date() method in
the anonymous class.

Das könnte Ihnen auch gefallen