23 views

Uploaded by jocansino4496

jhkjhkjk

save

You are on page 1of 4

PRACTICAL EXAMINATION NO. 1

Polygon

Background:

Polygons are two-dimensional shapes formed by line segments. The segments are edges that meet in pairs

at corners called vertices. A polygon is regular if all its sides are equal and all its angles are equal.

For an n-sided regular polygon of side s, the angle at any vertex is , and the radii of the inscribed and

circumscribed circles are r and R respectively. A 5-sided regular polygon (pentagon) would be

represented as follows:

s

r

R

Required Task:

1. Create a RegularPolygon class to model any regular polygon. Use the following declarations as a

starting point for your lab work.

class RegularPolygon

{

private

private

private

private

int myNumSides;

double mySideLength;

double myR;

double myr;

//

//

//

//

# of sides

length of side

radius of circumscribed circle

radius of inscribed circle

// constructors

public RegularPolygon()

{

}

public RegularPolygon(int numSides, double sideLength)

{

}

// private methods

private void calcr()

{

}

ITPROGX3 – Practical Examination 1 2nd TERM, SY 2015-2016

(Page 1)

The default constructor creates a 3-sided polygon (triangle). This angle can be determined as follows: n2 180 n where n represents the number of sides. Write two constructor methods. . 3. 4. The other constructor takes an integer value representing the number of sides and a double value representing the length of side. and constructs the corresponding regular polygon. This value is determined simply as the number of sides. s: perimeter ns ITPROGX3 – Practical Examination 1 2nd TERM. SY 2015-2016 (Page 2) . n.private void calcR() { } // public methods public double vertexAngle() { } public double Perimeter() { } public double Area() { } public double getNumside() { } public double getSideLength() { } public double getR() { } public double getr() { } } 2. Write a method that calculates the perimeter. Write a method that calculates the vertex angle. times the length of a side.

s represents the length of a side and csc() is the trigonometric function. An alternative is to replace π with 180 in all the formulas here and use following method from the Math Class to convert from degrees to radians: Math.5. It can be calculated as: area 1 2 2 nR sin 2 n where n represents the number of sides and R represents the radius of the circumscribed circle. R can be calculated as: R 1 s csc 2 n where n represents the number of sides. R. The cosecant function is not part of the Java Math Class. s represents the length of a side. SY 2015-2016 (Page 3) . ITPROGX3 – Practical Examination 1 2nd TERM. however. It can be calculated as: r 1 s cot 2 n where n represents the number of sides. for example. cotangent. The inscribed circle is the circle that can be drawn inside of the regular polygon such that it is tangent to every side of the polygon. r. The circumscribed circle is the circle that intersects each vertex of the polygon.PI produces the value of π. the cosecant of an angle can be calculated as the reciprocal of the sine as follows: csc 1 sin 7. cosecant. and cot() is the trigonometric function. Note: the built-in Java method math. Write a method that calculates the radius of the inscribed circle. We use the value π instead of 180 in the formula because the Java math functions assume that angles are given in radians instead of degrees. the smaller circle in the diagram above. for example the larger circle in the diagram above. Write a method that calculates the area of the regular polygon. however. Write a method that calculates the radius of the circumscribed circle.toRadians(double angdeg) The cotangent function is not part of the Java Math library. the cotangent of an angle can be calculated as the reciprocal of the tangent as follows: cot 1 tan 6.

length of side = 0.00 46.00 area = 100. length of side = 2 Enneacontakaihenagon: number of sides = 91.05 176.00 135.5 Answers: Square Octagon Enneadecagon Enneacontakaihenagon n 4 8 19 91 s 10 5. 2.64 113. All trigonometric function in the Java Math Class take radians as the parameter.00 Instructions: 1.00 161.94 5.51 6.68 (Page 4) .00 6.86 164.08 7.07 radius of inscribed circle = 5.24 R 7. To convert an angle measured in degrees to the equivalent angle measured in radians use the following method from the Math Class: public static double toRadians(double angdeg) 9.5 ITPROGX3 – Practical Examination 1 2nd TERM. Write a testing class with a main() that constructs a RegularPolygon and calls each method.75 Enneadecagon: number of sides = 19. length of side = 10 Octagon: number of sides = 8.00 radius of circumscribed circle = 7.00 vertex angle = 90. length of side = 5. Test the default constructor by constructing a regular polygon with no parameters as follows: RegularPolygon poly = new RegularPolygon().04 r 5.75 2 0.00 45.07 7.01).00 159. SY 2015-2016 θ (degrees) 90. 3.24 Perimeter 40.99 7.8. Use the following values to test your functions: Square: number of sides = 4. A sample run of the program for a polygon with 4 sides of length 10 would give: number of sides = 4 length of side = 10.0 perimeter = 40.50 Area 100.00 38. Format all floating point values to two decimal places (0.

- 4037_s04_qp_1Uploaded bymstudy123456
- Digital System Processing Lab assignmentUploaded byVaishali Behl
- M45 Polar Conversion - EkPolarConvUploaded byNora
- Engtrig ReviewerUploaded byJason Española
- Kem Matematik PMRUploaded byAnonymous wYj5g0fJMu
- 401Spring14M1 SolutionsUploaded byLevis
- 1011 SS2 Mathematics 1stAssessment1 Sol (1)Uploaded bynatotush7886
- 1986 Mathematics Paper2Uploaded byGeorge Chiu
- Maths Xi Fb Mcqs & Short qUploaded byficpeshawar
- 3. Kesetimbangan PartikelUploaded byGalih Indra Sukmana
- Class 10 Mathematics Part 2 of 2Uploaded byTapas Banerjee
- Grade 12 Cumulative ExercisesUploaded bylornehess
- Mathematics Past Question and Answer for Pre-University StudentsUploaded byChristopher Olasupo
- Aqa Mfp2 Qp Jun13Uploaded byprsara1975
- Basic DifferentiationUploaded byVarshLok
- graphing sine and cosine functionsUploaded byapi-287537110
- 1.TAREA DE TRIGONOMETRÍAUploaded byAlejandro0910
- Class XI Math Question 2011 the CollegiateUploaded bySyed Noaman
- 80583557 Pset Complex Variables 2 9 Problems, StahlUploaded byErik Rogoff
- 2015_10_mathematics_sa1_05Uploaded byjgkrishnan
- Appendix TablesUploaded byRonald QC
- IsC Class 12 Mathematics Sample Paper 2Uploaded byVishnu Khanna
- C4 Solomon H Question paperUploaded bySachitra Wijethunga

- DigitalLab ECCE 2008Uploaded byjocansino4496
- 13-javascript-introduction-120708105031-phpapp01.pptUploaded byjocansino4496
- 2015-2016-2nd-classlistUploaded byjocansino4496
- Padre Pio Prayer SheetUploaded byMae Dela Torre Borla
- Computer Engineering CurriculumUploaded byjocansino4496
- Introduction to ProgrammingUploaded byjocansino4496
- Topic 5_Karnaugh MapUploaded bysafuan_alcatra
- Good Moral (Repaired)Uploaded byjocansino4496
- Programming in VB.NETUploaded byRohitKumarBirla
- Padre Pio Prayer SheetUploaded byMae Dela Torre Borla
- AC11_sol.pdfUploaded byRishikeshMalviya
- Project 06Uploaded byjocansino4496
- Curriculum 2011Uploaded byjocansino4496
- Project 03Uploaded byjocansino4496
- Final ProjectUploaded byjocansino4496
- Feu Eac Lab Activity 7 c Arrays2Uploaded byjocansino4496
- Dtr Sir CecogoUploaded byjocansino4496

- 7903756-Dibujo-Tecnico.pptUploaded byErnestoQuiñonesGóngora
- Http Projecteuclid.org DPubS Repository 1.0 Disseminate View=Body&Id=PDF 1&Handle=EuclidUploaded bykuldipkatiyar198570
- BIOMECANICAUploaded byChristian Andres Carrasco Muñoz
- circunferencia-111205070537-phpapp02Uploaded byTadeu Pereira
- MENSCH, James - After_Modernity.docUploaded byAnna Luiza Coli
- Ecuación de la circunferenciaUploaded byAMYNNXXXX
- Heinbockel - Tensor Calculus - PartUploaded byapi-3835172
- 08032018Uploaded byDiego Castrol
- Crítica de La Ciudadanía Parte 4Uploaded bymes_reis
- transformaciones_espacialesUploaded byLuis Felipe Saldias Grájeda
- EJERCICIOS DE CALCULO INTEGRALUploaded byEugenio Ricardo Mamani Llaca
- Geometria-Diferencial-LipschutzUploaded byDagoberto Olarte Rom.
- evaluacion geometriaUploaded byzandorb
- Solid Angle Dependency (2)Uploaded byHayden Tornabene
- Matemáticas LimitesUploaded byDayelit Oropeza
- Reflexiones Sobre El espacio la luzUploaded byjobcha
- El_minimalismo_de_tadao.pdfUploaded byluz
- Geometria Dos SolidosUploaded bypcmcampos
- Apuntes_Analisis_ConvexoUploaded byJulian Andres Gutierrez Londoño
- LÍNEAS EQUIPOTENCIALESUploaded bySergio A. Lopez Quispe
- Secuencia 3 de Geometría AnalíticaUploaded byRené Domingo Franco Pedraza
- Chap-IIUploaded bysalimkaboura
- 2 Cuerpos Rigidos Capitulo 3Uploaded by'Luuis Feernandoo' Zapata Enriquez
- lec_week3asfasdfasdfUploaded byShahimulk Khattak
- HW4-SolUploaded byAlberto Villa
- campo escalar y campo vectorialUploaded byJhon Alvaro H
- 1evaluacion 5 ABC 01 Set Salida OnemUploaded byRonaldoQuiñonezPaucar
- 05 - The Geometry Guide 4th EditionUploaded byrecoveryp
- Primitive Virtual Negative Charge (WWW.OLOSCIENCE.COM)Uploaded byFausto Intilla
- 151018_GD_T_Basics_Wall_Chart.pdfUploaded byBasavaraj Kottur