Computer Science, asked by devendrachawda073, 2 months ago


Write a program to calculate area of a rectangle whose length is 17 mts and width is 23 mts.​

Answers

Answered by ıtʑFᴇᴇʟɓᴇãᴛ
18

\mathfrak{\huge{\underline{\red{Answer :-}}}}

public class {

public static void main(String[] strings) {

final double length = 17;

final double width = 23;

double area = length * width ;

System.out.printf("Area is %.1f * %.1f = %.2f \n", width, height, area);

}

}

______________________________________

  • length = 17

  • width = 23

The area = 17 × 23

391

Answered by ItzShradha
0

PROGRAM:-

#include<iostream.h>

#include<iomanip.h>

#include<conio.h>

class area

{

private:

int length, width ,area ;

public:

void input()

{

cout<< "\n Enter the length and breadth of rectangle respectively:- \n ";

cin>>length>>width;

}

void calculate ()

{

area = length x width ;

}

void output ()

{

cout<<" \n The area of rectangle is = "<< area;

}

};

void main()

{

clrscr();

area a;

a.input();

a.calculate();

a.output();

getch();

}

NOTE:-

The above program works for any relevant input values.

asper your question length = 17 mts and width = 23 mts. so area of rectangle will be length x breadth which will be 391 mts square.

EXPLAINATION :-

OBJECT :- It's an identifiable entity with different characters and behaviors.

CLASS :- It's an way of grouping the objects having similar characteristics and behavior.

ACCESS SPECIFIERS :- Access specifiers are the keywords which controls the access of data members and member functions of the class.

Private, public and protected are three access specifiers.

private access specifier is also known as default access specifier because without writing the keyword private, we can declare the members of private.

DOT OPERATOR ( . ) :- It's an operator which is used to access the public members outside of the class. it is also known as member access specifier.

MEMBER DATA :- The set of all variables of the class is known is member data.

MEMBER FUNCTION :- The set of all operations of the class is known as member functions.

I've bolded the keywords! Thank ya! ;)

Similar questions