OOPDP-Lab SP-21
Day 1:
Q1. Take input from user a character variable in a program and if the value is alphabet then print "Alphabet" if it’s a number then print "Digit" and for other characters print "Special Character"
Q2. Write a program to add all the values in a given number and check if the sum is prime number or not.
Ex: 1234->10, not prime.
Q3. Write a program to find the largest 2 numbers and the smallest 2 numbers in the array initialized by the user
Q4. Write a program to print the element of an array that has occurred the highest number of times
Ex: Array -> 10,20,10,30,40,100,99 O/P:10.
Day 2:
Q1. Write a Java program to print the Fibonacci series upto N.
Ex: N = 89; 0 1 2 3 5 8 13 21 34 55 89.
Q2. Write a program to take input of 10 students marks in an array. Find out the mean of the marks and print the marks which are greater than the mean.
Q3. Find the sum of the series :
1+(1+2)+(1+2+3)+........+(1+2+3+.....+N)
Q4. Write a java program to check whether a number is palindrome or not.
Ex: 1001 is a Palindrome
Day 3:
Q1. Write a program to reverse the elements of a given 2*2 array. Four integer numbers need to be passed as Command-Line arguments
Ex: I/P O/P
1 2 4 3
3 4 2 1
Q2. Write a program to find the greatest number in a 3*3 array. The program is supposed to receive 9 integer numbers as command-line arguments.
Ex: I/P O/P
1 2 3 9
3 4 5
6 7 9
Q3. Write a program in Java with class Rectangle with the data fields:
- width
- length
- area
- color
The length, width, and area are of double type and the color is of string type.
The methods are:
-
set_length()
-
set_width()
-
set_color()
-
find_area().
Create two objects of the rectangle and compare their area and color. If area and color same for the objects then display “Matching Rectangles” otherwise display “Non-Matching Rectangle”.
Ex: For rectangle one:
1
2 Red For rectangle two: 2 1 RedOutput:
Rectangles Matched Area: 2
Color is Red