The Function will be able to calculate the area of the following polygons: Right triangles, Rectangles, and regular polygons. It will do so by taking the following inputs: - numSides – a double of the number of sides the polygon has - sideLengths – a double of the length or lengths of sides of the polygon   The program should determine if the inputs are formatted properly. The rules are:  - numSides must be a positive integer number with values greater than or equal to 3. - When numSides is 3 or 4, sideLengths can either be a scalar or an array with two values. - When numSides is greater than 4, sideLengths must be a scalar.   To determine if a number is an integer, you can use the rem function. rem returns the remainder of whole number division. It has the following syntax: remainder = rem(numerator, denominator); Where remainder is the remainder of numerator/denominator. To use this to find whether a number is an integer, use rem in the following way: remainder = rem(number, 1); When number is an integer, remainder will be 0. Otherwise, remainder will be nonzero. To determine how many numbers are contained in an array, use the length function. The length function has the following syntax: N = length(arrayName); Where N is the number of elements (i.e. the number of numbers) contained in array arrayName. 3 different ways of calculating area of your polygon. - When numSides is 3 and sideLengths is an array with two numbers, you will calculate the area of a right triangle, where the two numbers inside of sideLengths are the sides of the triangle that are not the hypotenuse.   When numSides is 4 and sideLengths is an array with two numbers, you will calculate the area of a rectangle where the two numbers inside of sideLengths are your two different lengths for the sides of your rectangle.   In all other valid cases, the scalar sideLengths is the length of all sides of your polygon, no matter what numSides is.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The Function will be able to calculate the area of the following polygons: Right triangles, Rectangles, and regular polygons.

It will do so by taking the following inputs:
- numSides – a double of the number of sides the polygon has
- sideLengths – a double of the length or lengths of sides of the polygon  

The program should determine if the inputs are formatted properly. The rules are: 
- numSides must be a positive integer number with values greater than or equal to 3.
- When numSides is 3 or 4, sideLengths can either be a scalar or an array with two values.
- When numSides is greater than 4, sideLengths must be a scalar.  

To determine if a number is an integer, you can use the rem function. rem returns the remainder of whole
number division. It has the following syntax: remainder = rem(numerator, denominator);


Where remainder is the remainder of numerator/denominator. To use this to find whether a
number is an integer, use rem in the following way: remainder = rem(number, 1);


When number is an integer, remainder will be 0. Otherwise, remainder will be nonzero.
To determine how many numbers are contained in an array, use the length function. The length
function has the following syntax: N = length(arrayName);

Where N is the number of elements (i.e. the number of numbers) contained in array arrayName.


3 different ways of calculating area of your polygon.
- When numSides is 3 and sideLengths is an array with two numbers, you will calculate the
area of a right triangle, where the two numbers inside of sideLengths are the sides of the
triangle that are not the hypotenuse.  

When numSides is 4 and sideLengths is an array with two numbers, you will calculate the
area of a rectangle where the two numbers inside of sideLengths are your two different
lengths for the sides of your rectangle.  

In all other valid cases, the scalar sideLengths is the length of all sides of your polygon, no
matter what numSides is. 

Expert Solution
Step 1

As no language is mentioned so I used Matlab

answer is 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education