You are on page 1of 2

Assignment Project work Java Programming Language- Batch 2006 Note: 1. Solve any 10 programs' 2.

Each Program carries 10 marks 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 SimpleInterest 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 acepted 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 displayFruit() 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, 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: Students are required to submit the code & output of the program in the soft copy only on Pgdit3@scdl.net *************************************************************************** Practice Sample Examination Questions 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 DatePrinter with a method to print todays 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 printDate() method in the anonymous class.

***************************************************************************

You might also like