polygon side must be positive; otherwise, the program outputs invalid. • For any other wrong input, the program outputs invalid. • The result must only keep the first two decimal digits with rounding. • Crcumference and perimeter mean the same thing. • Do not add any cout statements except for the final answer as specified above. • Do not add "Enter a number", or any similar prompts. • Also note that the automatic grader is case-sensitive; so "Invalid" is wrong but "invalid" is correct. • You may add any librarles needed. vo Program Input: • A single line that takes in a string value to determine which shape to calculate the circumference for. • A single line that takes in the number of polygon sides •Asingle line that depending on the case takes in either the circle radius or the polygon side length. Program Output: •Asingle line that outputs either the circumference of the circle or the polygon perimeter rounded to th nearest two digits. Sample Testcase 0:

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
Topic Video
Question
#include #include #include #include using namespace std; int main (){ const double PI = 3.14159265359; return 0; }
• The radius and the length of a polygon
side must be positive; otherwise, the
program outputs invalid.
• For any other wrong input, the
program outputs invalid.
• The result must only keep the first two
decimal digits with rounding.
• Circumference and perimeter mean
the same thing.
• Do not add any cout statements
except for the final answer as specified
above.
• Do not add "Enter a number", or any
similar prompts.
• Also note that the automatic grader is
case-sensitive; so "Invalid" is wrong
but "invalid' is correct.
• You may add any librarles needed.
I/0
Program Input:
•A single line that takes in a string value
to determine which shape to calculate
the circumference for.
• A single line that takes in the number
of polygon sides
• A single line that depending on the
case takes in either the circle radius or
the polygon side length.
Program Output:
• A single line that outputs either the
circumference of the circle or the
polygon perimeter rounded to th
nearest two digits.
Sample Testcase 0:
Input:
CC
6
1.5
Output:
8.16
Sample Testcase 1:
Input:
PP
9
3
Output:
18.47
Sample Testcase 2:
Input:
PP
3
10
Output:
invalid
Transcribed Image Text:• The radius and the length of a polygon side must be positive; otherwise, the program outputs invalid. • For any other wrong input, the program outputs invalid. • The result must only keep the first two decimal digits with rounding. • Circumference and perimeter mean the same thing. • Do not add any cout statements except for the final answer as specified above. • Do not add "Enter a number", or any similar prompts. • Also note that the automatic grader is case-sensitive; so "Invalid" is wrong but "invalid' is correct. • You may add any librarles needed. I/0 Program Input: •A single line that takes in a string value to determine which shape to calculate the circumference for. • A single line that takes in the number of polygon sides • A single line that depending on the case takes in either the circle radius or the polygon side length. Program Output: • A single line that outputs either the circumference of the circle or the polygon perimeter rounded to th nearest two digits. Sample Testcase 0: Input: CC 6 1.5 Output: 8.16 Sample Testcase 1: Input: PP 9 3 Output: 18.47 Sample Testcase 2: Input: PP 3 10 Output: invalid
In this exercise, we will either have a circle inside
a polygon for which we will calculate the
circumference, or we shall have a polygon inside
a circle for which we will calculate its perimeter
(circumference).
You are required to write a program that accepts
one of two strings:
• "CC" which refers to the case Circle
Circumference.
• "PP" which refers to the case Polygon
Perimeter.
If the user chooses CC, then the program waits
for the user to input the number of sides of the
polygon first, then the length of one of its sides. It
outputs the circumference of the largest circle
that can fit inside this polygon.
If the user chooses PP, then the program waits
for the user to input the number of sides of the
polygon first, then the radius of the circle, It
outputs the circumference of the largest polygon
that fits inside the circle.
B
B
A circle inside a hexagon (polygon with 6 sides)
An octagon (polygon with 8 sides) inside a circle
Hint: To solve this program, it might be easier to
divide the polygon into triangles all connected at
the center. This way, as you already know the
number of sides of the polygon, you can derive
the angles, and use basic geometry and
trigonometry to solve this question.
IMPORTANT NOTE
• The circle and the polygon share the
same center.
• At all times, the sides of the circle and
polygon touch each other,
• The number of polygon sides must
never be less than five; otherwise, the
program outputs invalid.
• The radius and the length of a polygon
side must be positive; otherwise, the
program outputs invalid.
Transcribed Image Text:In this exercise, we will either have a circle inside a polygon for which we will calculate the circumference, or we shall have a polygon inside a circle for which we will calculate its perimeter (circumference). You are required to write a program that accepts one of two strings: • "CC" which refers to the case Circle Circumference. • "PP" which refers to the case Polygon Perimeter. If the user chooses CC, then the program waits for the user to input the number of sides of the polygon first, then the length of one of its sides. It outputs the circumference of the largest circle that can fit inside this polygon. If the user chooses PP, then the program waits for the user to input the number of sides of the polygon first, then the radius of the circle, It outputs the circumference of the largest polygon that fits inside the circle. B B A circle inside a hexagon (polygon with 6 sides) An octagon (polygon with 8 sides) inside a circle Hint: To solve this program, it might be easier to divide the polygon into triangles all connected at the center. This way, as you already know the number of sides of the polygon, you can derive the angles, and use basic geometry and trigonometry to solve this question. IMPORTANT NOTE • The circle and the polygon share the same center. • At all times, the sides of the circle and polygon touch each other, • The number of polygon sides must never be less than five; otherwise, the program outputs invalid. • The radius and the length of a polygon side must be positive; otherwise, the program outputs invalid.
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Instruction Format
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