0% found this document useful (0 votes)
7 views3 pages

Atif Khaliq Fa20-Bee-082 Oop Asg.

The document is a Java program that defines a Rectangle class with properties for color, width, and height. It includes methods to get and set these properties, as well as to calculate the area and perimeter of the rectangle. The main method allows user input for width and height, then outputs the calculated area and perimeter.

Uploaded by

insahmad374
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Atif Khaliq Fa20-Bee-082 Oop Asg.

The document is a Java program that defines a Rectangle class with properties for color, width, and height. It includes methods to get and set these properties, as well as to calculate the area and perimeter of the rectangle. The main method allows user input for width and height, then outputs the calculated area and perimeter.

Uploaded by

insahmad374
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

NAME: Atif Khaliq

ROLL NO: FA20-BEE-082


CLASS: BS (EE)

ASSIGMENT NO 2:

import java.io.*;
import java.util.Scanner;

public class Rectangle {


private String color;
private int width, height;
public String getColor()
{
return color;

}
public void setColor(String newColor)
{
this.color=newColor;
}

public int getWidth()


{
return width;

}
public void setWidth(int newWidth)
{
this.width=newWidth;
}

public int getHeight()


{
return height;

}
public void setHeight(int newHeight)
{
this.height=newHeight;
}

public int CalculateArea()


{
return height*width;

public int CalculatePeimeter()


{
return 2*(height+width);

public static void main(String args[])


{
Rectangle R = new Rectangle();
Scanner sc = new Scanner (System.in);
int Height,Width;
System.out.println("Enter the Width of Rectangle : ");
Width= sc.nextInt();
R.width=Width;
System.out.println("Enter the Height of Rectangle : ");
Height= sc.nextInt();
R.height=Height;
System.out.println("Area of Rectangle : "+ R.CalculateArea());
System.out.println("Perimeter of Rectangle : "+ R.CalculatePeimeter());

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy