1 views

Uploaded by Ravi Prakash Verma

- math literature
- Math Literature
- Traces That Leave Nothing Behind - Robin Evans
- Computer Science
- Geometric Computation: Foundations for Design
- Form 2 Half Yearly Revision Sheet 2015
- Maths
- robotics unit sneha tharayil
- 3rd area
- Programs on File Handling
- CG Pracs
- unit Unit1.docx
- es table grade 3 eoy for parcc final
- Create and Change Customer Data Through BAPI Class Method XD01 XD02
- Math 2
- 546
- Example Program for Polynomial Addition Using C
- Unit 1final
- 1. Introduction to OOP
- c# interview questions 3

You are on page 1of 2

12

Date:

Objects and Classes

Aim:

To write a java program to calculate the area and perimeter of shapes.

Source Code:

class square{

int sqarea(int side){

int area = side * side;

return(area);

}

int sqpari(int side){

int pari = 4 * side;

return(pari);

}

}

class rectangle{

int rectarea(int length,int breadth){

int area = length * breadth;

return(area);

}

int rectpari(int length,int breadth){

int pari = 2*(length + breadth);

return(pari);

}

}

public class ObjectClass{

public static void main(String args[]){

int sarea1,sarea2,pari1,pari2;

int rectarea1,rectarea2,rectpari1,rectpari2;

square sq = new square();

rectangle rect = new rectangle();

int a=20;

System.out.println("Side of first square = " + a);

sarea1 = sq.sqarea(a);

pari1 = sq.sqpari(a);

System.out.println("Area of first square = " + sarea1);

System.out.println("Parimeter of first square = " + pari1);

a = 30;

System.out.println("Side of second square = " + a);

sarea2 = sq.sqarea(a);

pari2 = sq.sqpari(a);

System.out.println("Area of second square = " + sarea2);

System.out.println("Parimeter of second square = " + pari2);

int x = 10, y = 20;

System.out.println("Length of first Rectangle = " + x);

System.out.println("Breadth of first Rectangle = " + y);

rectarea1 = rect.rectarea(x,y);

rectpari1 = rect.rectpari(x,y);

System.out.println("Area of first Rectangle = " + rectarea1);

System.out.println("Parimeter of first Rectangle = " + rectpari1);

x = 15;

y = 25;

System.out.println("Length of second Rectangle = " + x);

System.out.println("Breadth of second Rectangle = " + y);

rectarea2 = rect.rectarea(x,y);

rectpari2 = rect.rectpari(x,y);

System.out.println("Area of second Rectangle = " + rectarea2);

System.out.println("Parimeter of first Rectangle = " + rectpari2);

}

}

Output:

Javac ObjectClass.java

java ObjectClass

Side of first square = 20

Area of first square = 400

Parimeter of first square = 80

Side of second square = 30

Area of second square = 900

Parimeter of second square = 120

Length of first Rectangle = 10

Breadth of first Rectangle = 20

Area of first Rectangle = 200

Parimeter of first Rectangle = 60

Length of second Rectangle = 15

Breadth of second Rectangle = 25

Area of second Rectangle = 375

Parimeter of first Rectangle = 80

Result:

Thus the java program has been written to calculate the area and perimet

er of shapes.

- math literatureUploaded byapi-201574058
- Math LiteratureUploaded byttmathmaniac
- Traces That Leave Nothing Behind - Robin EvansUploaded bymics86
- Computer ScienceUploaded byPAUL
- Geometric Computation: Foundations for DesignUploaded byBookLove
- Form 2 Half Yearly Revision Sheet 2015Uploaded byGrace Yun
- MathsUploaded byantonydinoj
- robotics unit sneha tharayilUploaded byapi-233736029
- 3rd areaUploaded byapi-247262407
- Programs on File HandlingUploaded byArnab Chakrabarti
- CG PracsUploaded byKaustubh Mejari
- unit Unit1.docxUploaded byahmad
- es table grade 3 eoy for parcc finalUploaded byapi-115680157
- Create and Change Customer Data Through BAPI Class Method XD01 XD02Uploaded byFaizan Zia
- Math 2Uploaded byLyno Rey Tejada
- 546Uploaded bySherlock Wesley Conan
- Example Program for Polynomial Addition Using CUploaded byjosyulasb6149
- Unit 1finalUploaded byPrasanth Menon
- 1. Introduction to OOPUploaded byMaslimona Ritonga TechCelup
- c# interview questions 3Uploaded byprematjob
- Dependency Injection Zendcon 2010 101104172213 Phpapp01Uploaded byMac Garr
- (Undergraduate Lecture Notes in Physics) Kerry Kuehn-A Student's Guide Through the Great Physics Texts_ Volume III_ Electricity, Magnetism and Light-Springer (2015).pdfUploaded byaklamos
- BookListUploaded bypiaoger
- DB_CH4Uploaded byaziz6shodiyev
- add mathUploaded byZul Azmi CankChank
- The Decorator's Assistant: Volume 1Uploaded byDodger
- OOPS ConceptUploaded byapi-3853733
- 5 Lesson 5 Inheritance SlidesUploaded byMd Asfar Khan
- mathgen-612244600Uploaded byAndrewHung
- ok - Copy (3)Uploaded byisaac

- ApacheUploaded byRavi Prakash Verma
- cycle-IUploaded byRavi Prakash Verma
- GettingStarted_With Data Quality GuideUploaded byManimala Vidyasagar
- GettingStarted_With Data Quality GuideUploaded byManimala Vidyasagar
- Structured RepresentationsUploaded byRavi Prakash Verma
- Doc Data QualityUploaded byRavi Prakash Verma
- Nov- 1406- VII Sem Software EnggUploaded byRavi Prakash Verma
- May- 6106- VII Sem Software EnggUploaded byRavi Prakash Verma
- May-7473- VII SEm Software EnggUploaded byRavi Prakash Verma
- FMS Admission Brochure 2012Uploaded bySonam Pandita
- DQ 951 InstallationAndConfigurationGuide EnUploaded byychacha
- In for Matic a Data Quality 9Uploaded bysasikannadev
- PC 910 TransformationGuide EnUploaded byGyara Prashanth Kumar
- 2VxworksTrainingUploaded byRavi Prakash Verma
- Spark Week 1 LectureUploaded byRocksta927
- Java Pgm10Uploaded byRavi Prakash Verma
- Java Pgm14Uploaded byRavi Prakash Verma
- Java Pgm20Uploaded byRavi Prakash Verma
- java pgm9Uploaded byRavi Prakash Verma
- Java Pgm12Uploaded byRavi Prakash Verma
- Java Pgm15Uploaded byRavi Prakash Verma
- Java Pgm15Uploaded byRavi Prakash Verma
- Java Pgm18Uploaded byRavi Prakash Verma
- Java Pgm11Uploaded byRavi Prakash Verma
- Java Pgm13Uploaded byRavi Prakash Verma
- Java Pgm16Uploaded byRavi Prakash Verma
- Java Pgm16Uploaded byRavi Prakash Verma
- Java Pgm16Uploaded byRavi Prakash Verma
- Java Pgm17Uploaded byRavi Prakash Verma
- Java Pgm19Uploaded byRavi Prakash Verma

- Garment Cutting 1Uploaded byxtyomonigho
- AP Physics 1 - Review Expressing Motion Visually Mathmatically (1)Uploaded byBUG
- Ch-7 (Circular Motion)Uploaded bythinkiit
- 2.8 Gravitational Force.doc physics form 4 chapter 2 forceUploaded byEzra Loganathan Muniandi
- dynamics of circular motionUploaded by'Joenabie Maxey Gamao
- IGCSE Physics NotesUploaded bylhngu
- How to Use Vernier Calipers and Micrometer Screw GaugeUploaded byJohn Adams Villamoran
- Fisika Linear MotionUploaded byHarjono Jn
- The Anthropometry of Forest Machine Operators In the Southern USAUploaded byPanacota_5401
- Physical QuantitiesUploaded bylhngu
- 20131021Uploaded byWesley John Hofstetter
- MotionUploaded byKs Wang
- BS en 755-7 1995 TablesUploaded byestabeja
- 52223505 Physics Lesson 2 2 Analysing Motion GraphsUploaded byHafeeza Yusof
- Rmc Plant Calibration ReportUploaded byRakesh Para
- Physics MonthlyUploaded byRhys Jansen
- Radimatic EngUploaded byPablo Antonio Nuñez Gallardo
- Motion ProblemsUploaded byMarielle Krizanne Catral
- FRL differece from Km34+000+000 to Km 83+320Uploaded byAnonymous eKt1FCD
- physicUploaded byTakiYa SaruMaru
- Encycbrita Mathematics in Context Reallotment Geometry and Measurement 2006Uploaded byMireya Jumbo
- 9th gravitation 2014 45 solved questionsUploaded byapi-242227794
- Tp5 Rectangle TrianglesUploaded byrajdeepghai5607
- Tamil Units of Measurement.htmlUploaded byshiva
- Trade Mathematics MeasurementUploaded byAlex Moralda
- Kuliah 2,3,4,5 Kinematika BendaUploaded byAldi
- 2.1 Analysing Linear MotionUploaded byRizal Salasiah
- Free Fall NotesUploaded byTrah Nur
- Physics class 9 CBSE testUploaded byndthokare
- book back answersUploaded byMohammed Aadil