Lab_Exercise (1) (1)
Lab_Exercise (1) (1)
1. Write a java program which accept your first and second name and display it together.
2. Write a java program which receives a number and determine whether it is odd or even.
3. Write a java program which adds even numbers between 0 and any positive integer number
given by the user.
4. Write an object-oriented program which receives list of numbers and display the largest number.
5. Write a java program which finds the average, maximum, minimum, and sum of three numbers
given by the user.
6. Write a java program which reads 10 integers from the keyboard in the range 0 - 100, and count
how many of them are larger than 50.
7. Write a java program which takes an integer from the user and display the factorial of that
number.
8. Write a java program that accept the name of 10 student and display alphabetically.
9. Write a java program that accept a word and check it palindrome or not?
10. Write a java program which accepts an integer and reverse digits
11. Accept two dimensional array and display after multiply each element by two.
12. Write a program that accepts two numbers from the keyboard. The main() method should first
accept the two numbers and then passes these values to methods named add(), sub(), mul() and
div(), to calculate the sum, difference, product and quotient of the numbers, respectively.
Finally, the main() method should accept the returned result and display it on the consol. [Hint:
your java program will have five methods of which one is the mandatory main() method. ]
13. Write a program that calculates the area of a rectangle. The main() method should first accept
the width and height of the rectangle and then passes these values to method named
rectangleArea(). Method rectangleArea() calculates the area of the rectangle using the formula
width*height and return the result. main() method should accept the returned result and display
it.
14. Write a java program which takes D number of days and displays the number of Y years, M
months, W weeks and d days from the entered number D. (If entered value of D is 544, the
output should be: 544 days is equal to 1 year, 5 months, 4 weeks, and 1 day).
15. Write a java program which computes sum of prime numbers between 0 and 1000. Your
program which contains a method isPrime(int a) to check if the number is prime number.
Count how many prime numbers found and display all of them.
16. write a Java program that accepts two matrices from the user, allows for their multiplication,
and displays the result. Your program should include methods for accepting a matrix, displaying
a matrix, and performing the multiplication. Ensure that you handle cases where matrix
multiplication is not possible (i.e., the number of columns in the first matrix must equal the
number of rows in the second).
17. Accept a paragraph and display the number of words in the paragraph.
18. Write a simple java program that show how to pass object reference to a method with simple
example.
19. Write a java program that accept the name, department and address of five student and display
it.