Question

1. Write a program that determines the area and perimeter of a square. Your program should...

1. Write a program that determines the area and perimeter of a square. Your program should accept the appropriate measurement of the square as input from the user and display the result to the screen.

Area of Square = L (squared)

Perimeter of Square = 4 * L

2.  Write a program that determines the area and circumference of a circle. Your program should accept the appropriate measurement of the circle as input from the user and display the result to the screen.

Area of Circle = pi * radius (squared)

Circumference of Circle = 2 * pi * radius

3. Write a program that determines the area of a triangle and trapezium. Your program should accept the appropriate measurement of the triangle and trapezium as input from the user and display the result to the screen.

Area of Triangle = 1/2 * base * height

Area of Trapezium = (base1 + base2)/ 2 * height

4. Write a program that allows the user enter in 5 numbers representing the salaries of 5 employees, your program should display as output the average salary of the employees.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

#include<iostream>
using namespace std;
int main()
{
int L;
cout<<"Enter Side of a Square : ";
cin>>L;
cout<<"Area of Square : "<<L*L<<endl;
cout<<"Perimeter of Square : "<<4*L;
return 0;
}

2)

#include<iostream>
using namespace std;
int main()
{
   float r, area, circum;
   cout<<"Enter the radius of the circle : ";
   cin>>r;
   area=3.14*r*r;
   circum=2*3.14*r;
   cout<<"Area of the circle = "<<area<<endl;
   cout<<"Circumference of the circle = "<<circum<<endl;
   return 0;
}

3)

#include <iostream>
using namespace std;
float areaTrapezium(float a, float b, float h)
{
return (1.0 / 2 * (a + b) * h);
}
float areaTriangle(int b,int h)
{
   return (0.5)*h*b;
}
int main()
{
int base,heightTri;
   float base1,base2,height;
   cout<<"Enter the value of base1 : ";
   cin>>base1;
cout<<"Enter the value of base2 : ";
   cin>>base2;
   cout<<"Enter the height : ";
   cin>>height;
   cout << "Area of Trapezium = " <<
areaTrapezium(base1, base2, height) << endl;
cout<<"Enter the value of base for triangle : ";
   cin>>base;
cout<<"Enter the value of heightTri : ";
   cin>>heightTri;
   cout << "Area of Triangle = " <<
areaTriangle(base, heightTri) << endl;
   return 0;
}

4)

#include <iostream>
using namespace std;
int main()
{
   float salary[5],sum,average;
   cout<<"Enter the salaries of five employees : ";
   for(int i=0;i<=4;i++)
   {
       cin>>salary[i];
       sum=sum+salary[i];
   }
   average = sum/5;
   cout<<"Average salary of five employees is : "<<average<<endl;
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
1. Write a program that determines the area and perimeter of a square. Your program should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Q2) Interface Create a program that calculates the perimeter and the area of any given 2D...

    Q2) Interface Create a program that calculates the perimeter and the area of any given 2D shape. The program should dynamically assign the appropriate calculation for the given shape. The type of shapes are the following: • Quadrilateral 0 Square . Perimeter: 4xL • Area:LXL O Rectangle • Perimeter: 2(L+W) • Area:LxW Circle Circumference: I x Diameter (TT = 3.14) Area: (TT xD')/4 Triangle (assume right triangle) o Perimeter: a+b+c O Area: 0.5 x base x height (hint: the base...

  • write a c programming Write a program that will calculate the perimeter, area and volume of...

    write a c programming Write a program that will calculate the perimeter, area and volume of a is is entered by the user. Your program will display the radius, perimeter, area and volume to the monitor and will also save them to a file called "circlePAV.txt". Your program should prompt the user for the radius until the user enters -1. Use the following structure. typedef struct ( float radius; float area, float perimeter; float volume; ylinder Figure>

  • Using the algorithm information below, program a calculator for the area and circumference of a circle....

    Using the algorithm information below, program a calculator for the area and circumference of a circle. Answer in C LANGUAGE !! Algorithm for Area and Circumference of a Circle: Inputs: - radius of the circle Outputs: - the area of the circle - the circumference of the circle Relevant Constants and Formulas: - area of a circle = PI x Radius x Radius - circumference of a circle = 2 x PI X Radius Main Algorithm (numbered steps) 1. Input...

  • (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator...

    (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...

  • Geometric calclator use python to do this program. Write a program that displays the following menu:...

    Geometric calclator use python to do this program. Write a program that displays the following menu: 1. Calculate the area of circle 2. calculate the area of rectangle 3. calculate the area of triangle 4. Quit Enter your choice (1-4). if the user enters 1, your program should ask for the radius of the circle and then display its area. Use the formula to calculate the circle's area: Area = pi*r^2 Use 3.14149 for Pi and the radius of the...

  • Write a program that calculates the area and circumference of a circle. It should ask the...

    Write a program that calculates the area and circumference of a circle. It should ask the user first to enter the number of circles n, then reads the radius of each circle and stores it in an array. The program then finds the area and the circumference, as in the following equations, and prints them in a tabular format as shown in the sample output. Area = πr2 , Circumference = 2πr, π = 3.14159 Sample Output: Enter the number...

  • Problem: Given information about a circle, rectangle and a triangle, calculate the area of the shape...

    Problem: Given information about a circle, rectangle and a triangle, calculate the area of the shape from the information supplied. Write pseudocode to solve this problem and write a Python program that asks the user to input the required information for a shape and then calculates the area of the shape. Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1...

  • Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects....

    Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- rectangle 2 -- circle 3 -- triangle 4 -- quit If the user selects choice 1, the program should find the area of a rectangle. rectangle area = length * width If the user selects choice 2, the program should find the area of a circle. circle area = PI * radius * radius...

  • Write a java program that compute the circumference and area of a circle from the user...

    Write a java program that compute the circumference and area of a circle from the user input for a radius.

  • Write a C program named assignment04.cpp that will ask for and read in a float for...

    Write a C program named assignment04.cpp that will ask for and read in a float for a radius ask for and read in a float for the height each of the following functions will calculate some property of a shape (area, volume, circumference, etc) The functions will accept one or two parameters (radius and/or height) and return the proper calculation. There is no input/output (cin or cout) in the function – just the calculation write the following functions float areaCircle(float...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT