+ 1

Modify code to calculate the area and perimeter of geometric figures

Hello guys can anyone help modify my codes to calculate for the area and perimeter of the geometric figures in the code??The program should allow the user to go back to the menu after an invalid selection. The program should exit after 3 failed attempts. Here is the link: https://code.sololearn.com/c1lvOjg9Ons8/#cpp

10th Jul 2022, 12:34 AM
EOK
EOK - avatar
12 Antworten
+ 2
What's the difference between this question and the one linked below? https://www.sololearn.com/discuss/3057775/?ref=app
10th Jul 2022, 12:41 AM
Emerson Prado
Emerson Prado - avatar
+ 2
EOK your code is fine. You just forgot to close a few lines with ; and you have some a stray { or } If you look at the errors it actually tells you were the issues are in the code. https://code.sololearn.com/cO8Yc14l3Xqm/?ref=app
10th Jul 2022, 12:46 AM
Chris Coder
Chris Coder - avatar
+ 2
EOK You will need a while loop. And a variable to keep track of invalid answer. And increment the invalid count.
10th Jul 2022, 8:15 AM
Chris Coder
Chris Coder - avatar
+ 2
EOK my suggestions: 1. Create functions to calculate areas and perimeters for each shape 2. Input the shape selection in a for loop with 3 iterations 3. Use a switch statement to call the calculator function specific to the selected shape Get used to dividing the code in small functions. This helps a lot in code maintainability.
11th Jul 2022, 4:24 AM
Emerson Prado
Emerson Prado - avatar
+ 1
Emerson Prado No worries they are still learning how it all works.
10th Jul 2022, 12:44 AM
Chris Coder
Chris Coder - avatar
+ 1
@Emerson Prado the one I've written just measures the area and has not menu to specify b/n whether to measure area or perimeter
10th Jul 2022, 12:56 AM
EOK
EOK - avatar
0
@Emerson Prado the link below is the code I've written please
10th Jul 2022, 12:44 AM
EOK
EOK - avatar
0
Thanks Chris Coder, but how do I modify to get the results I'm expecting.
10th Jul 2022, 12:48 AM
EOK
EOK - avatar
0
Chris Coder Can you edit my code and rewrite if for me to suit the preference stated?...so that at least I can learn from it.
10th Jul 2022, 10:05 AM
EOK
EOK - avatar
0
Sorry I can not write the code for you. But I did find someone else working on the problem. Perhaps you both can team up to help each other out. https://www.sololearn.com/Discuss/3058377/?ref=app
11th Jul 2022, 3:38 AM
Chris Coder
Chris Coder - avatar
0
Chris Coder Thanks I'm already done with the program code and it works great.
11th Jul 2022, 4:11 AM
EOK
EOK - avatar
0
Thanks Emerson Prado but I'm already done with the program..you efforts are appreciated
11th Jul 2022, 4:27 AM
EOK
EOK - avatar