Question

Using the c++ language 1) Create a function that calculates the area of a circle "circeArea...

Using the c++ language

1) Create a function that calculates the area of a circle "circeArea ()". The function should take a single float parameter radius and return a float area.

2) Create a function to calculate the area of a rectangle.

3) Creat a function to calculate the area of a triangle when given base and height as parameters provided by the user.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

// 1
float circeArea(float radius) {
    return 3.14159 * radius * radius;
}

// 2
float rectangleArea(float length, float width) {
    return length * width;
}

// 3
float triangleArea(float base, float height) {
    return 0.5 * base * height;
}

int main() {
    float radius, length, width, base, height;
    cout << "Enter radius of circle: ";
    cin >> radius;
    cout << "Area of circle is " << circeArea(radius) << endl;

    cout << "Enter length of rectangle: ";
    cin >> length;
    cout << "Enter width of rectangle: ";
    cin >> width;
    cout << "Area of rectangle is " << rectangleArea(length, width) << endl;

    cout << "Enter base of triangle: ";
    cin >> base;
    cout << "Enter height of triangle: ";
    cin >> height;
    cout << "Area of triangle is " << triangleArea(base, height) << endl;
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Using the c++ language 1) Create a function that calculates the area of a circle "circeArea...
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
  • create C program that: Has a triangle function (which receives and sends no arguments) to: Calculates...

    create C program that: Has a triangle function (which receives and sends no arguments) to: Calculates the area of ANY* triangle (prompts the user for necessary values.) Uses integer values and displays them in a field width of 8. Provides an answer to the user such as follows: The area of the triangle with base 7 and height 8 is 28. Has a circle function (which receives and sends no arguments) to: Prompts the user for necessary values. Accurately calculate...

  • Question 4.4: Write an overloaded function of function area with 3 (float) parameters. This function should...

    Question 4.4: Write an overloaded function of function area with 3 (float) parameters. This function should calculate and print out the product of the 3 parameters. Question 4.4: Write the main function to test question 4.1, 4.2, 4.3, 4.4. Your main function should ask if the user want to calculate the area of a rectangle or a circle or a triangle then print out the result accordingly. (Use switch structure). For example: Please enter (r) for rectangle, (t) for triangle,...

  • 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...

  • 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...

  • #1 Write a java program which calculates the area of either a Triangle or a Rectangle....

    #1 Write a java program which calculates the area of either a Triangle or a Rectangle. Use Scanner to take an input field to tell you if the area to be calculated is for a Triangle or is for a Rectangle. Depending on that input - the program must call either the Triangle method or the Rectangle method. Each of those methods must receive 2 input fields from the user - one for base and one for height in order...

  • Use Visual Basic language The function, FindAreaOfTriangle, calculates the area of a triangle given the base...

    Use Visual Basic language The function, FindAreaOfTriangle, calculates the area of a triangle given the base and height. Write code that calls the function with: Base = 8; Height = 16.3 and returns the answer to dblAreaOfTriangle.     Function FindAreaOfTriangle(dblBase As Double, dblHeight As Double) As Double         Dim dblArea As Double         dblArea = (dblBase * dblHeight) / 2         Return dblArea     End Function Display keyboard shortcuts for Rich Content Editor

  • Create a program that calculates the area of various shapes. Console Specifications Create an abstract class...

    Create a program that calculates the area of various shapes. Console Specifications Create an abstract class named Shape. This class should contain virtual member function named get_area() that returns a double type. Create a class named Circle that inherits the Shape class and contains these constructors and member functions: Circle(double radius) double get_radius() void set_radius(double radius) double get_area() Create a class named Square that inherits the Shape class and contains these constructors and member functions: Square(double width) double get_width() void...

  • Q2: Write a menu-driven C program using switch-case to calculate the following: 1. Area of circle...

    Q2: Write a menu-driven C program using switch-case to calculate the following: 1. Area of circle 2. Area of square 3. Area of rectangle The program should use the following functions properly: void displayMenu() //a function that will display the menu options to the user int getChoice() //a function that will input the user choice and returns it float calculate(int choice) //a function that reads the required inputs based on the user choice, and returns the area of the shape...

  • 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...

  • c++ language 1) Create a function that prints a greeting when called with a name such...

    c++ language 1) Create a function that prints a greeting when called with a name such as greeting ("Elona") 2) Create a function that squares a double number and returns the result as a double. 3) Create a function that takes 5 int numbers and returns the average as a float 4) Create a single function that gives a greeting, calculates the average of 5 grades but does not return a value. Hint: Use return type void and a string...

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