+ 1

I need help please

Iā€™m to write a C++ program to calculate the area and perimeter of these 5 geometric figures(rectangle,triangle,parallelogram,cylinder,circle). The program should allow the user to go back to the menu after an invalid selection. The program should exit after 3 failed attempts I want a helper to write a code on this for me please.

10th Jul 2022, 10:19 PM
Patrick Oduro Afrifa
21 Answers
+ 4
Some questions first: First: Do you have an try attempt of yours? Second: What's the input Format? Can they chose an form or is just height and width given and you need to calculate all forms with them. Third: Are they any other specifics like using classes or else?
10th Jul 2022, 10:40 PM
Felix Alcor
Felix Alcor - avatar
+ 2
To have someone write a code for you (read: do your assignment) will ruin your learning experience, especially when the "helper" does all the work. We don't do that kind of "help" here.. I personally don't see that as a form of helping.. As @Felix said, share your code bit link, to show that you have put an effort in. We help you fix a problem, not doing the entire work.
11th Jul 2022, 1:41 AM
Ipang
+ 2
The member here claims to have solved it. Maybe you can reach out to them. https://www.sololearn.com/Discuss/3057985/?ref=app
11th Jul 2022, 4:39 PM
Chris Coder
Chris Coder - avatar
+ 1
Can you Insert your attempt here and an example Input and Output. I don't understand what you meant by my Input question
10th Jul 2022, 11:03 PM
Felix Alcor
Felix Alcor - avatar
+ 1
Patrick Oduro Afrifa Is this a class assignment, I have seen another member asking for this.
11th Jul 2022, 3:32 AM
Chris Coder
Chris Coder - avatar
+ 1
Patrick Oduro Afrifa , the questions from Felix Alcor are not rethoric. They are key for us to help you. If you need to solve this quick, be quick in providing us the needee info. 1. You said you tried. Pls edit your question description with a link to your attempt in Code Playground. Also, include in the question description an explanation of your difficulties. This is where the help starts from. 2. Which inputs should the user provide, and in which format? Do this change from one geometric shape to another? 3. Which are the other requirements? The quicker you explain the problem, the quicker you get a solution.
11th Jul 2022, 4:12 AM
Emerson Prado
Emerson Prado - avatar
+ 1
Patrick Oduro Afrifa Finally, how to allow the user 3 attempts for the shape input: Build a do...while loop with 2 exit conditions: a valid input or 3 invalid ones. Alternatively, a for loop with 3 iterations, with a break statement in the case of a valid input.
11th Jul 2022, 11:24 PM
Emerson Prado
Emerson Prado - avatar
+ 1
CLEERIC DEY Pls answer with concepts and hints, for the same reasons explained to Felix Alcor . More: pls avoid walls of code, both in questions and answers. They make the answers harder to follow. Specially with lots of blank lines...
12th Jul 2022, 2:11 PM
Emerson Prado
Emerson Prado - avatar
0
First:yeah ive tried but its an assignment and im to submit it tomorrrow and its urgent please Second: using the formulas of the respective shapes for both the area amd perimeter Third:else
10th Jul 2022, 10:48 PM
Patrick Oduro Afrifa
0
Im to submit to tomorrow please can you help
10th Jul 2022, 11:10 PM
Patrick Oduro Afrifa
0
I can't help when I don't understand how the Input's Made and I could make things faster when I have a Base (your code)
10th Jul 2022, 11:14 PM
Felix Alcor
Felix Alcor - avatar
11th Jul 2022, 1:32 PM
Patrick Oduro Afrifa
0
I want to make this program exit after 3 failed attempts,what do i do please?
11th Jul 2022, 1:33 PM
Patrick Oduro Afrifa
0
Patrick Oduro Afrifa I made it so that no input get taken after the 3 time. Just Check with Input: 20 20 20 12 Output: Invalid number Invalid number Invalid number The Input 12 will Not be taken anymore. https://code.sololearn.com/c8SUUxZde5Id/?ref=app
11th Jul 2022, 1:43 PM
Felix Alcor
Felix Alcor - avatar
0
Patrick Oduro Afrifa The reason I always ask these central info in the question description, and not in answers, is that answers tend to get lost among others. Keep that in mind for future questions.
11th Jul 2022, 11:13 PM
Emerson Prado
Emerson Prado - avatar
0
Patrick Oduro Afrifa Some good practices that can really help you, both in this and in future codes: 1. Use functions. Your main function is too long, with a huge if/else if/else block. You can get it way more readable with each specific shape in a separate function, then a switch statement calling one of them depending in the input. Use of functions will also prevent the profusion of variables in the same scope. 2. Use descriptive names for variables, functions, etc. You'll thank yourself when debugging a long code with lots of names. 3. Make proper use of indentation. It's only for visual reference (except in Python), but visual reference is important for readability - consequently, for maintainability.
11th Jul 2022, 11:22 PM
Emerson Prado
Emerson Prado - avatar
0
Felix Alcor Pls avoid answering with finished code, as this makes the OP skip the most important part of learning: the reasoning to the solution. Instead, prefer giving hints for the OP to find the solution.
11th Jul 2022, 11:25 PM
Emerson Prado
Emerson Prado - avatar
0
Just include ur logic for prgm in while loop and ask ch as input for choice of input and take a counter to count attempts u can add condn if counter==3 break..
12th Jul 2022, 3:40 AM
Soham Kulkarni
Soham Kulkarni - avatar
0
#include <iostream> using namespace std; int main() { float length , width , height , base , radius , side1 , side2 , side3; char c; cout << "what figure do you want ?\n c for circle\n r for rectangle\n t for triangle "<< endl; cout << "enter the choice "; cin >> c; if (c == 'c') { cout << "enter radius of the circle"; cin >> radius; cout << "area =" << 3.142 *(radius *radius) << endl; cout << "Perimeter = " << 2* 3.142 *radius << endl; } else if (c == 'r') { cout << "enter the length and width of the rectangle"; cin >> length >> width; cout << "area =" << length* width << endl; cout << "Perimeter = " << (2*length)+ (2*width) << endl; } else if (c == 't') { cout << "enter the base and height of the triangle"; cin >> base >> height; cout << "area =" << 0.5* base* height << endl; cout << "Perimeter = " << (side1 + side2 + side3) << endl; } return 0; } I could not finish it
12th Jul 2022, 4:08 AM
CLEERIC DEY
CLEERIC DEY - avatar
0
Prabhu Hiremath Pls don't use other posts for unrelated questions. And when you search for a Job, Look here what you can do. We can't look up for Jobs for you. https://www.sololearn.com/Discuss/3058876/?ref=app
12th Jul 2022, 3:05 PM
Felix Alcor
Felix Alcor - avatar