Write a Matlab script to:
  1. Ask the user their name.
  2. Display to the screen statement that the program will calculate perimeter of a regular polygon.
  3. Find out what type of polygon they’d like to calculate (triangle, square, pentagon, hexagon, heptagon, octagon).
  4. Enter the length of one side of their polygon.
  5. Calculate the perimeter.
  6. Display the perimeter to the screen (as more than a numeric value).
  7. Have user decide whether or not to perform another calculation.
  8. Add some command after the loops and/or conditionals to indicate you have reached the end of your program.
Do your best to incorporate a for loop, while loop, and conditional statements into your code.
Use your coding personality to incorporate the user’s name into some of your statements. Also, do not forget your header.

댓글 수: 3

Rik
Rik 2020년 11월 8일
This is the question from your teacher. What is your question?
Filiz Demian
Filiz Demian 2020년 11월 8일
How do I make it to calculate the perimeter? What code words do I use? I know how to ask for the shape and length. But I don't know how to make it calculate the perimeter. Please help.
Rik
Rik 2020년 11월 9일
Since you only have specific shapes, you should look up the formulae for the perimeter of each shape (or think yourself how you would find the perimeter of a triangle and a square). You might want to use switch-case to select the correct formula from your code.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Polygonal Shapes에 대해 자세히 알아보기

질문:

2020년 11월 8일

댓글:

Rik
2020년 11월 9일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by