0% found this document useful (0 votes)
2 views2 pages

Csf201 1000015771

The document contains a graded lab assignment by Manan Jain, a Btech CSE student, featuring two programming tasks. The first task involves creating a Rectangle class and a Square subclass to calculate areas, while the second task demonstrates matrix multiplication using two 3x3 integer matrices. Both tasks include complete Java code implementations and output statements.

Uploaded by

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

Csf201 1000015771

The document contains a graded lab assignment by Manan Jain, a Btech CSE student, featuring two programming tasks. The first task involves creating a Rectangle class and a Square subclass to calculate areas, while the second task demonstrates matrix multiplication using two 3x3 integer matrices. Both tasks include complete Java code implementations and output statements.

Uploaded by

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

Name: Manan Jain

Sap: 1000015771
Branch: Btech CSE
Roll no: 210102477

GRADED LAB-2

Ans1. class Rectangle {


protected double length;
protected double width;

public Rectangle(double length, double width) {


this.length = length;
this.width = width;
}

public double getLength() {


return length;
}

public double getWidth() {


return width;
}

public double getArea() {


return length * width;
}
}

class Square extends Rectangle {


public Square(double side) {
super(side, side);
}
}

public class Main {


public static void main(String[] args) {
Rectangle rectangle = new Rectangle(4, 5);
System.out.println("Rectangle Area: " + rectangle.getArea());

Square square = new Square(5);


System.out.println("Square Area: " + square.getArea());
}
}

Ans2. public class MultiplyTwoMatrix {

public static void main(String[] args) {


int[][] x = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int[][] y = {{ 5, 6, 7}, {8, 9,10}, {2,3, 4}};
int[][] multi = new int[3][3];
int i, j;

for(i = 0; i < x.length; i++)


{
for(j = 0; j < x[0].length; j++)
{
multi[i][j] = x[i][j] * y[i][j];
}
}
System.out.println("------ The Multiplication of two Matrix ------");

for(i = 0; i < x.length; i++)


{
for(j = 0; j < x[0].length; j++)
{
System.out.format("%d \t", multi[i][j]);
}
System.out.println("");
}
}
}

You might also like