0% found this document useful (0 votes)
9 views

Java Lab Exercise 3

Uploaded by

ARYA BHAGAT
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Java Lab Exercise 3

Uploaded by

ARYA BHAGAT
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Week -3

1. Write a Java program that defines a class Rectangle with the following attributes:

• length (of type double)


• width (of type double)

The class should have the following methods:

1. setValues(double len, double wid): A method to set the values of length and
width.
2. calculateArea(): A method that returns the area of the rectangle.
3. display(): A method that prints the length, width, and area of the rectangle.

The program should:

1. Ask the user for the number of rectangles.


2. Create an array of Rectangle objects.
3. Take user input for length and width of each rectangle and store them in the
respective objects.
4. Display the details of all rectangles, including their area.

2. Write a Java program that takes n integers as input from the user, stores them in an array, and
finds the maximum element in the array.
3. Write a Java program that takes an array of n integers as input from the user and prints the array
in reverse order.
4. Write a Java program that takes n integers as input from the user, stores them in an array, and
counts how many numbers are even and how many are odd.

You might also like