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

Object Oriented Programing: Name System Id Instuctor Program Section

This document contains an assignment submission for a BSSE-31 programming course. It includes responses to two questions - one on jagged arrays in Java with an example, and another on writing a program to calculate and display the area and perimeter of a triangle with sides of 3, 4, and 5 units by creating a Triangle class with appropriate data members and methods.

Uploaded by

BIM 1234
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)
17 views

Object Oriented Programing: Name System Id Instuctor Program Section

This document contains an assignment submission for a BSSE-31 programming course. It includes responses to two questions - one on jagged arrays in Java with an example, and another on writing a program to calculate and display the area and perimeter of a triangle with sides of 3, 4, and 5 units by creating a Triangle class with appropriate data members and methods.

Uploaded by

BIM 1234
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/ 5

OBJECT ORIENTED PROGRAMING

NAME Saad Irfan

SYSTEM ID NUML S22 15306 (SP21289)

INSTUCTOR Mis. Iqra Shahzad

PROGRAM BSSE-31 (Morning)

SECTION II -A

ASSIGNMENT #1
Q#01
What is Jagged Array in Java? Example with
example.

 A Jagged Array is an array of arrays such that member arrays


can be of different sizes, i.e., we can create a 2-D array but
with a variable number of columns in each row.
 Jaggad Array is also known as Ragged Array.
 Once the array is declared, you can define it as a Jagged array
as shown below:
myarray[1] = new int[2];

myarray[2] = new int[3];

myarray[3] = new int[4];

Once the array is created, you can initialize it with values.


Example

Output
Q# 02
Write a program for printing area and perimeter of
triangle having sides as 3,4,5 units. Make a java
Class named as Triangle for this purpose. Use
appropriate data members.
Write a member function “Display” for calculation
and display these area and triangle.
Program
package SBT;

public class triangledata {


int a=3;
int b=4;
int c=5;
float t_area;
int t_perimeter;

triangledata()
{
t_area=(a*c)/2f;
t_perimeter=a+b+c;
}
void display()
{
System.out.println("AREA of TRIANGLE is :"+t_area);

System.out.println("PERIMETER of TRIANGLE is :"+t_perimeter);


}
public static void main(String[] args) {

triangledata t= new triangledata();


t.display();
}

}
OUTPUT

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