Question

Exercise 1: Work programming exercise 4.1, page 150. Name it Pentagon, Run the program with different input values. Document the code and follow the output model shown in the sample run in the textbook (limit the precision of the result to two digits to the rnight of the decimal point)

media%2F31b%2F31b6d803-5b8b-469f-ac43-f9
Please write this program as simple as possible and use comments throughout to explain what is happening. Thank you!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

PYTHON CODE:

# importing math package for sin and tan calculations
import math

# getting length from the center to a vertex from the user
r=float(input("Enter the length from the center to a vertex: "))

# calculating the length of the side
x=2 * r *math.sin(math.pi/5)

# calculating the area of the pentagon using given formula
area=(5 * x * x)/(4 *math.tan(math.pi/5))

# displaying the area
print('The area of the pentagon is %.2f' %area)

SCREENSHOT FOR OUTPUT:

Enter the length from the center to a vertex: 5.5 The area of the pentagon is 71.92

Add a comment
Know the answer?
Add Answer to:
Please write this program as simple as possible and use comments throughout to explain what is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • *** SIMPLE C PROGRAM WILL RATE GOOD**** PLEASE LEAVE COMMENTS THROUGHOUT THE CODE SO I CAN...

    *** SIMPLE C PROGRAM WILL RATE GOOD**** PLEASE LEAVE COMMENTS THROUGHOUT THE CODE SO I CAN SEE WHAT IS HAPPENING AND LEARN, THANK YOU! Write a program that implements the following disk-scheduling algorithms: a. FCFS b. SSTF c. SCAN d. C-SCAN e. LOOK f. C-LOOK Your program will service a disk with 5,000 cylinders numbered 0 to 4,999. The program will generate a random series of 1,000 cylinder requests and service them according to each of the algorithms listed above....

  • I need help with this assignment. Please include comments throughout the program. Thanks Develop an algorithm...

    I need help with this assignment. Please include comments throughout the program. Thanks Develop an algorithm and write the program in java for a simple game of guessing at a secret five-digit code. When the user enters a guess at the code, the program returns two values: the number of digits in the guess that are in the correct position and the sum of those digits. For example, if the secret code is 13720, and the user guesses 83521, the...

  • In Java. Exercise 4: Design and implement a Java program for programming exercise 6.11, page 236...

    In Java. Exercise 4: Design and implement a Java program for programming exercise 6.11, page 236 (name it ComputeCommissions), to print out table of sales amount and commission as shown in the textbook. Follow the instructions in the problem statement. Document your code, and organize and space the outputs as shown in the textbook using escape characters.

  • PLEASE UPLOAD or Write a simple PSEUDO CODE AND JAVA CODE for this program WITH COMMENTS...

    PLEASE UPLOAD or Write a simple PSEUDO CODE AND JAVA CODE for this program WITH COMMENTS IN BOTH TELLING WHAT EACH PART DOES. (I NEED BOTH CODES NOT JUST ONE OR THE OTHER) Problem Statement A golf club has a small tournament consisting of five golfers every weekend. The club president has asked you to design a program that does the following: Reads player’s names and their scores from the keyboard for each of the five golfers and simulates writing...

  • Please write comments with the program. Python programming!! Part III - write student data In this...

    Please write comments with the program. Python programming!! Part III - write student data In this part the program should create a .csv file and fill it with generated student information. The program should: Ask the user for a name for the .csv file (use your own name for the exercise) Create the .csv file with columns named - ID, first-name, GPA Based on the information received in part I, generate and fill students information in the CSV file Tell...

  • PYTHON Programming Exercise 2: Create a Simple Cost Calculator Write a program that displays input fields...

    PYTHON Programming Exercise 2: Create a Simple Cost Calculator Write a program that displays input fields (item name and cost) and calculates and displays the calculated costs. The program should do the following: Provide data entry areas for item name and cost. Calculate and display the subtotal of all items. Adds a sales tax of 6% and calculate and displays the total cost. Enter the following values into your program. Mother Board $200. RAM $75. Hard Drive $72. Video Graphics...

  • Please use simple java code and comments no arrays Write a program that displays all the...

    Please use simple java code and comments no arrays Write a program that displays all the numbers from 100 to 1,000. ten per line, that are divisible by 5 and 6. Numbers are separated by exactly one space.

  • PLEASE UPLOAD or Write a simple pesudo code and java code for this program with comments...

    PLEASE UPLOAD or Write a simple pesudo code and java code for this program with comments in both describe what things do. Problem Statement A golf club has a small tournament consisting of five golfers every weekend. The club president has asked you to design a program that does the following: Reads player’s names and their scores from the keyboard for each of the five golfers and simulates writing them to a file called "golf.dat" Entering "Z" for the player...

  • Add high level comments throughout the program to explain what each line of code does. Finally,...

    Add high level comments throughout the program to explain what each line of code does. Finally, use a diagramming tool (Visio, Lucidchart, MSPaint, paper & pen) to create a flowchart of the code below. path = "/Users/user1/data/baby_names/" myyear = input("Please provide the year to be searched:") babyname = input("Please provide the baby name to be searched:") babyname = babyname.capitalize() baby_counts = count_babies(myyear, babyname) print("There were {0} boys and {1} girls with that name in {2}".format( baby_counts[0], baby_counts[1], myyear)) def count_babies(year,...

  • Create an algorithm to count the number of 1’s in a 32-bit number. Implement the program in a high level language like...

    Create an algorithm to count the number of 1’s in a 32-bit number. Implement the program in a high level language like C or Java. It does not need to run for me, but the code should be included in a text document called FirstnameLastnameHLA3.txt along with your assignment submission. Implement the program in MIPSzy Assembly language. Use the high level code as comments to the right of the Assembly code as the textbook does. If you write that MIPSzy...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT