1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Fudgin [204]
3 years ago
7

You are required to write a calculator for Geometric shapes(Circle, Square, and Rectangle). The basic idea is that you willprovi

de the information regarding a geometric shape and yourprogram will calculate the area, circumference and perimeter.
Computers and Technology
1 answer:
denis23 [38]3 years ago
4 0

Answer: The c++ program to calculate area and perimeter for different geometric shapes is given below.

#include <iostream>

using namespace std;

void circle();

void square();

void rectangle();

int main() {  

string shape;

char choice;  

do

{

cout<<"Enter the geometrical shape (circle, square, rectangle)." <<endl;

cin>>shape;  

if(shape == "circle")

       circle();        

   if(shape == "square")

       square();        

   if(shape == "rectangle")

       rectangle();        

   cout<<"Do you wish to continue (y/n)"<<endl;

   cin>>choice;    

   if(choice == 'n')

       cout<<"quitting..."<<endl;        

}while(choice != 'n');

return 0;

}

void circle()

{

   float area, circumference;

   float r, pi=3.14;    

   cout<<"Enter the radius of the circle"<<endl;

   cin>>r;    

   circumference = 2*pi*r;

   area = pi*r*r;    

   cout<<"The circumference is "<<circumference<<" and the area of the circle is "<<area<<endl;    

}

void square()

{

   float area, perimeter;

   float s;    

   cout<<"Enter the side of the square"<<endl;

   cin>>s;    

   perimeter = 4*s;

   area = s*s;    

   cout<<"The perimeter is "<<perimeter<< " and the area of the square is "<<area<<endl;

}

void rectangle()

{

   float area, perimeter;

   float b, h;    

   cout<<"Enter the breadth of the rectangle"<<endl;

   cin>>b;    

   cout<<"Enter the height of the rectangle"<<endl;

   cin>>h;    

   perimeter = 2*(b+h);

   area = b*h;    

   cout<<"The perimeter is "<<perimeter<< " and the area of the rectangle is "<<area<<endl;

}

 

OUTPUT

Enter the geometrical shape (circle, square, rectangle).

circle

Enter the radius of the circle

3.56

The circumference is 22.3568 and the area of the circle is 39.7951

Do you wish to continue (y/n)

n

quitting...

Explanation:

The program performs for circle, square and rectangle.

A method is defined for every shape. Their respective method contains the logic for user input, computation and output.

Every method consists of the variables needed to store the dimensions entered by the user. All the variables are declared as float to ease the computation as the user can input decimal values also.

No parameters are taken in any of the methods since input is taken in the method itself.

You might be interested in
In what way, if any, has community building changed in the age of digital media? People’s community building has not changed in
hichkok12 [17]

Answer:

People are now more willing to share highly personal information with strangers. Match each type of digital health, wellness, and security with examples of potential violations.

5 0
3 years ago
It's important to understand that even information systems that do not use computers
Delvig [45]

Answer:

yes I am not sure if you have any questions or concerns please visit the plug-in settings to determine how attachments are handled the situation in the measurements of the season my dear friend I am not sure if you can send you a great day to day basis of

6 0
3 years ago
.Pretend you are ready to buy a new computer for personal use.First, take a look at ads from various magazines and newspapers an
andriy [413]

Answer:

Brainly is not meant to give paragraph answers to large questions.

In a computer (desktop)

There are 8-9 main components to a PC

Motherboard

CPU

GPU (for gamers)

RAM

SSD

HDD

PSU

Cooling fans (for AMD processors stock fans are included)

Case (some fans included)

I personally build my computers (desktops) as its cheaper and I won't have to pay a build fee.

7 0
4 years ago
The value of the expression 20.0 * (9/5) + 32.0 is
Rama09 [41]

Answer:

68

Explanation:

9/5 = 1.8

20 * 1.8 + 32

20 * 1.8 = 36

36 + 32 = 68

7 0
3 years ago
Explain the concept of “survival of the fittest”
klasskru [66]

Answer:

i think thats a line from  the lorax

Explanation:

4 0
3 years ago
Other questions:
  • Given the following stream of accesses to a 4-block fully associative cache with LRU replacement, determine whether the access i
    8·1 answer
  • Which question is most closely related to the field of biology? A.How thick is a paper bag? B.What determines the growth rate of
    10·2 answers
  • Type the correct answer in the box. Spell all words corre ctly.
    15·2 answers
  • Write a function checkPalindrome that accepts a single argument, a string. The function should return true (Boolean) if the stri
    15·1 answer
  • When the Hyper-V role is added to a Windows Server 2016 server, the hypervisor creates the individual environments, each of whic
    5·1 answer
  • Questions to ask people on how corona has affected the religion sectors​
    10·1 answer
  • Which statements are true? Select 4 options.
    9·1 answer
  • What is an algorithm?
    11·1 answer
  • What is the result when you run the following program?
    9·2 answers
  • In best practice, should you use all lowercase, all uppercase or a mixture of cases in HTML tag names?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!