Write a program that prompts the user to enter the sides and their length of a regular polygon and display its area.
****Using c++
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int sides;
float length;
cout<<"Enter the Number Sides of Regular Polygon :
";
cin>>sides;
if(sides < 0) {
cout << "The shape cannot
have minus number sides.";
return 0;
}
cout<<"Enter Length of Each Sides : ";
cin>>length;
if(length < 0) {
cout << "The shape cannot
have minus length of sides.";
return 0;
}
float perimeter=sides*length; // calculate perimeter = sides*length of each side
float deg_to_rad = 3.1415926536/180; // degree to radian
float apothem=(length/tan((180/sides)*deg_to_rad))/2; // calculate apothem = length / 2*tan(180/side)
cout<<endl<<"Area of Regular Polygon With "<<sides<<" sides is : "<<0.5*perimeter*apothem<<" sq. unit.";
return 0;
}
Output :
Write a program that prompts the user to enter the sides and their length of a...
A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon isArea =Here, s is the length of a side. Write a program that prompts the user to enter the number of sides and their length of a regular polygon and displays its area. Here is a sample run:
A regular polygon is an n-side polygon in which all sides are of the same length and all angles have the same degree(i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon isHere, s is the length of a side. Write a program that prompts the user to enter the number of sides and their length of a regular polygon and displays its area.
Write a program that prompts the user to enter a length in feet and inches and outputs the equivalent length in centimeters. If the user enters a negative number or a nondigit number, throw and handle an appropriate exception and prompt the user to enter another set of numbers. Using Python
2. Write a program that prompts a user to enter the lengths of sides and angles for the two triangles described below. The program should calculate the length of the side of the triangle indicated below. Print the two answers to 3 decimal places onto the console screen Triangle 1 Read in the value of the angle, alpha, and the length, a, of the side indicated in the picture below. Calculate the length of the hypotenuse, c, of this right...
c++ Write a program that prompts the user to enter a length in feet and then enter a length in inches and outputs the equivalent length in centimeters. If the user enters a negative number or a non-digit number, throw and handle an appropriate exception and prompt the user to enter another set of numbers. Your error message should read A non positive number is entered and allow the user to try again.
Please help with 3.12 and 3.14 Write a program that prompts the user to enter the length of the star and draw a star, as shown in Figure 3.5a. (Turtle: display a STOP_sign) write a program that displays a STOP sign, as shown in Figure 3.5b. The hexagon is in red and the text is in white. (Turtle: draw the Olympic symbol) write a program that prompts the user to enter the radius of the rings and draws an Olympic...
Write a program that prompts the user to enter three integers and display the integers in non-decreasing order. For example if you enter 10 and 9 and 12, in the result we will first see 9, then 10 and then 12 (because 9 < 10 < 12). **using c++
Write a program that prompts the user to enter a question (string) and display whether the question is correct. It is correct if it ends with the question mark (?) ----vyrovusmyzustning%20Class.pdf Programs with String Class Write a program that prompts the user to enter a question (string) and display whether the question is correct. It is correct if it ends with the question mark (?) Ask a question? Ask a question? How old are you What is your name? That's...
Write a program in visual c# program named CheckMonth that prompts a user to enter a birth month. If the value entered is greater than 12 or less than 1, display an error message; otherwise, display the valid month with a message such as 3 is a valid month.
write a python program a) The program will prompt the user to enter the length of the two vertical sides. b) The length of the two horizontal sides will be twice as long as the length of the two vertical sides. c) The rectangle will be filled with the color green