+ 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
12 Antworten
+ 2
What's the difference between this question and the one linked below?
https://www.sololearn.com/discuss/3057775/?ref=app
+ 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
+ 2
EOK You will need a while loop. And a variable to keep track of invalid answer. And increment the invalid count.
+ 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.
+ 1
Emerson Prado No worries they are still learning how it all works.
+ 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
0
@Emerson Prado the link below is the code I've written please
0
Thanks Chris Coder, but how do I modify to get the results I'm expecting.
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.
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
0
Chris Coder Thanks I'm already done with the program code and it works great.
0
Thanks Emerson Prado but I'm already done with the program..you efforts are appreciated