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
Suppose that you have a multiplexer (mux) with 5 different inputs at the following bit-rates: (A) 20 Kbps, (B) 8 Kbps, (C) 12 Kb
sweet [91]
The answer is number:

C.- Kbps
7 0
3 years ago
Nowwwwwww pleasssssssss
Feliz [49]

the technique used is Data Validation

6 0
2 years ago
User ideas for ro blox?
AveGali [126]

Answer:

You can put random people, or something you like to do, like Soccer2347 (that was just an example) or your favorite animal, Horse990. But Rob lox has to approve it first

Explanation:

7 0
3 years ago
In function main prompt the user for a time in seconds. Call a user defined function to calculate the equivalent time in hours,
Molodets [167]

Answer:

#include <iostream>

#include <cmath>

using namespace std;

int main()

{

   cout<<"Enter time in seconds:";

   int time, hour, minutes, seconds,initialTime;

   

   cin>>time;

   initialTime = time;

   

   hour = floor(time / 3600);

   time = time % 3600;

   minutes = floor(time / 60);

   time = time % 60;

   seconds = time;

   cout<< initialTime<<" can be broken down into: "<<endl;

   cout<<hour << " hour(s)"<<endl;

   cout<<minutes <<" minutes"<<endl;

   cout<<seconds <<" seconds"<<endl;

   return 0;

}

Explanation:

The programming language use is c++

The module cmath was called to allow me perform some math operations like floor division, and the Iostream allows me to print output to the screen. Using namespace std allows me to use classes from the function std.

I prompt the user to enter time in second, then declare all the variables that will be used which include time, hour, minutes, seconds and initialTime.

initialTime is used to hold the the time input entered by the user and will be printed at the end no arithmetic operation is carried out on it.

Floor division (returns the quotient in a division operation) and Modulo (returns the remainder in a division operation) division is used to evaluate the hours, the minutes and the seconds.

The final answers are then printed to the screen.

I have uploaded the c++ file and a picture of the code in action

4 0
2 years ago
An assignment notebook is important because that is where students
melisa1 [442]
Answer:

Record all their assignments and due dates.
7 0
3 years ago
Read 2 more answers
Other questions:
  • You would like to know how many cells contain data. Which function should you use? COUNT MIN SUM ABS
    14·1 answer
  • NIST recommends selecting cloud providers that support strong encryption, have appropriate redundancy mechanisms in place, emplo
    11·1 answer
  • How does a barcode work?
    11·1 answer
  • Which of the following techniques is used with a state of nature of uncertainty? A. Decision tree B. Laplace C. Break-even analy
    6·1 answer
  • S.B. manages the website for the student union at Bridger College in Bozeman, Montana. The student union provides daily activiti
    7·1 answer
  • What is spread sheet software?​
    11·1 answer
  • Informed _________ will better manage complexities and enable more efficient manufacturing of goods.
    13·1 answer
  • HELLLLLLLLPPPPPPPPPPPP HHHHHHHHHEEEEEEEEELLLLLLPPPPPP MEEEEEEEE
    12·2 answers
  • Write a program that asks the user for the name of a text file. The program should display the first 10 lines of the file on the
    6·1 answer
  • Use the VBA Editor to create a new module. Type the following VBA code to createa custom depreciation function (be sure to inclu
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!