Program to convert perimeter
古いコメントを表示
Write a Matlab script to:
- Ask the user their name.
- Display to the screen statement that the program will calculate perimeter of a regular polygon.
- Find out what type of polygon they’d like to calculate (triangle, square, pentagon, hexagon, heptagon, octagon).
- Enter the length of one side of their polygon.
- Calculate the perimeter.
- Display the perimeter to the screen (as more than a numeric value).
- Have user decide whether or not to perform another calculation.
- 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
2020 年 11 月 8 日
This is the question from your teacher. What is your question?
Filiz Demian
2020 年 11 月 8 日
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 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!