Question

In: Computer Science

Create the appropriate variables and algorithm to calculate the following. Choose your own values for the...

Create the appropriate variables and algorithm to calculate the following. Choose your own values for the variables. Do not enter the code on this paper. Create a program that calculates and displays the calculation. Approximate pi (π) as 3.14159.

You do not need to create a new program for each question.

If certain math equations use the same variable name, then you only need to declare it once in your main function.

Separate each problem using comments, like seen in the example below.

Example 1: Area of a square/rectangle. Formula:

int main()

{

   // Example 1

float area, length, width;

length = 20;

width = 5;

area = length * width;

cout << "The area of a square with length " << length << " and width "

   << width << " is " << area << " square units.";

// Problem 1

// Problem 2

return 0;

}

  1. Area of triangle.

  1. Area of circle. Formula:

  1. Area of rhombus. Formula:

  1. Area of trapezoid. Formula:

  1. Area of a parallelogram. Formula:

  1. Volume of sphere. Formula:

  1. Volume of cone. Formula:

  1. Volume of cube. Formula:

  1. Volume of cylinder. Formula:

  1. Volume of square pyramid. Formula:

  1. Volume of pyramid. Formula:

  1. Perimeter of Rectangle. Formula:

  1. Midpoint. Formula:

  1. Calculate Absolute Value. i.e.:

  1. Slope. Formula:

  1. Parabola Axis of Symmetry. Formula:

  1. Sum and Difference of Cubes.
    • Sum:
    • Difference:

Solutions

Expert Solution

Source Code::

#include<bits/stdc++.h>
using namespace std;
int main()
{
    float area,length,width,height,base,radius,diagonal1,diagonal2,smallbase,volume,edge,perimeter;
    float x1,x2,y1,y2,value,midpoint,symmetry,x,y,a,b,sum,difference;
    //area of rectangle and square
    length=20;width=5;
    area=length*width;
    cout<<"The area of rectangle with length "<<length<<" and width "<<width<<" is "<<area<<" square units.\n";
    length=width=20;    //square
    area=length*width;
    cout<<"The area of square with length "<<length<<" and width "<<width<<" is "<<area<<" square units.\n";
  
    //area of triangle
    height=10;base=10;
    area=(1/2)*height*base;
    cout<<"The area of triangle with base "<<base<<" and height "<<height<<" is "<<area<<" square units.\n";
  
    //area of circle
    radius=10;
    area=3.14159*radius*radius;
    cout<<"The area of circle with radius "<<radius<<" is "<<area<<" square units.\n";
  
    //area of rhombus
    diagonal1=10;diagonal2=10;
    area=(1/2)*diagonal1*diagonal2;
    cout<<"The area of rhombus with diagonals "<<diagonal1<<" and "<<diagonal2<<" is "<<area<<" square units.\n";
  
    //area of trapezoid
    base=30;height=50;
    area=(base+smallbase)*height/2;
    cout<<"The area of trapezoid with base "<<base<<" and height "<<height<<" and smallbase "<<smallbase<<" is "<<area<<" square units.\n";
  
    //area of parallelogram
    base=100;height=50;
    area=base*height;
    cout<<"The area of parallelogram with base "<<base<<" and height "<<height<<" is "<<area<<" square units.\n";
  
    //volume of sphere
    radius=10;
    volume=(4/3)*3.14159*radius*radius*radius;
    cout<<"The volume of sphere with radius "<<radius<<" is "<<volume<<" cubic units.\n";
  
    //volume of cone
    radius=100;height=50;
    volume=3.14159*radius*radius*height/3;
    cout<<"The volume of cone with radius "<<radius<<" and height "<<height<<" is "<<volume<<" cubic units.\n";
  
    //volume of cube
    edge=10;
    volume=edge*edge*edge;
    cout<<"The volume of cube with edge "<<edge<<" is "<<volume<<" cubic units.\n";
  
    //volume of cylinder
    radius=10;height=10;
    volume=3.14159*radius*radius*height;
    cout<<"The volume of cylinder with radius "<<radius<<" and height "<<height<<" is "<<volume<<" cubic units.\n";
  
    //volume of square pyramid
    edge=10;height=20;
    volume=edge*edge*height/3;
    cout<<"The volume of square pyramid with base edge "<<edge<<" and height "<<height<<" is "<<volume<<" cubic units.\n";
  
    //volume of pyramid
    length=10;width=10;height=10;
    volume=length*width*height/3;
    cout<<"The volume of pyramid with length "<<length<<" and height "<<height<<" and width "<<width<<" is "<<volume<<" cubic units.\n";
  
    //perimeter of rectangle
    length=10;width=10;
    perimeter=2*(length+width);
    cout<<"The perimeter of rectangle with lenght "<<length<<" and width "<<width<<" is "<<perimeter<<" units\n";
  
    //midpoint
    x1=1;x2=2;y1=2;y2=3;
    cout<<"The midpoint is at ("<<(x1+x2)/2<<" , "<<(y1+y2)/2<<")\n";
  
    //Absolute value
    value=-100;
    cout<<"The Absolute value of value "<<value<<" is "<<fabs(value)<<" unit\n";
  
    //slope
    x1=1;x2=2;y1=2;y2=3;
    cout<<"The slope is "<<(y2-y1)/(x2-x1)<<endl;
  
    //symmetry of parabola
    b=10;a=10;
    symmetry=(-b)/(2*a);
    cout<<"The symmetry of parabola is "<<symmetry<<endl;
  
    //sum and difference of cube
    x=10;y=10;
    sum=(x+y)*(x*x-x*y+y*y);
    difference=(x-y)*(x*x+x*y+y*y);
    cout<<"The sum of cube with x "<<x<<" and y "<<y<<" is "<<sum<<" cubic units\n";
    cout<<"The difference of cube with x "<<x<<" and y "<<y<<" is "<<difference<<" cubic units\n";
    return 0;
}

OUTPUT::


Related Solutions

Construct your own coordination game, by selecting an appropriate game matrix (choose your own payoffs). Find...
Construct your own coordination game, by selecting an appropriate game matrix (choose your own payoffs). Find the Nash equilibrium (or equilibria) for this game. What do you need to change in your payoff matrix to obtain a potential game? Find the potential function for your proposed potential game.
Using Python, Establish random centroids according to the k , and create your own algorithm to...
Using Python, Establish random centroids according to the k , and create your own algorithm to make clusters: create a functions kmeans() that accepts a dataframe and k as parameters, and returns the clusters created.
Create a project charter. Choose a business of your own. The business must include (but is...
Create a project charter. Choose a business of your own. The business must include (but is not limited to) the following criteria: Clear business objective and a specific completion outcome. Project team has at least three members (not including you, the project manager), each with defined roles and responsibilities. Completion window of 180 days. Cost estimates that serve as the basis for a budget are used as part of the plan development process. Business Need. Project Objectives. Describe the business...
Create your own data type using a C++ structure. Assign values to a variable of that...
Create your own data type using a C++ structure. Assign values to a variable of that data type. Retrieve values from the variable of that data type. Description: In this lab you will choose the statements to create a program that: Creates a brand new data type called "Monster". Once created, creates a variable of type Monster and assign values to the variable and then display the contents. This lab will again take the form of a guided multiple-choice quiz...
Create your own Binomial Probability RV and Distribution 1. Describe your Binomial Experiment. Choose an n...
Create your own Binomial Probability RV and Distribution 1. Describe your Binomial Experiment. Choose an n of between 20 and 100: 2. Success = __________________________   Failure = _____________________________ 3. X ~ _____ (______, ______) 4. List or give the range of the values that X takes on: 5. Give the PDF formula for the RV: 6. Find the expected value and standard deviation for your random variable.   7. Write the probability questions described below about YOUR binomial RV and evaluate...
Assume that it is appropriate and meaningful to calculate the correlation coefficient of two variables X...
Assume that it is appropriate and meaningful to calculate the correlation coefficient of two variables X and Y. If the correlation coefficient, r, has a value -0.95 Select one: a. it is impossible to tell if there is a linearly relationship between the two variables b. there is a strong linear relationship between the two variables c. there is no relationship between the two variables d. the slope of the regression line will be -0.95 2. The father's height (in...
Please provide your own example of KNN algorithm
Please provide your own example of KNN algorithm
Draw and display a histogram for each of the two variables using appropriate BIN values from...
Draw and display a histogram for each of the two variables using appropriate BIN values from part (b) and comment on the shape of the two distributions. Hours Per Week Yearly Income ('000's) 18 43.8 13 44.5 18 44.8 25.5 46.0 11.3 41.1 18 43.3 16 43.6 27 46.2 27.5 46.8 30.5 48.2 24.5 49.3 32.5 53.8 25 53.9 23.5 54.2 30.5 50.5 27.5 51.2 28 51.5 26 52.6 25.5 52.8 26.5 52.9 33 49.5 15 49.8 27.5 50.3 36...
Choose a company of laptops of your own choice and explain the following characteristics of the...
Choose a company of laptops of your own choice and explain the following characteristics of the chosen product. 1) Substitutes and complements goods of the product and their implication. 2) Major current and past reason for variation in demand and supply.
create your own haunted house please 1.Where is your haunted house? Why did you choose this...
create your own haunted house please 1.Where is your haunted house? Why did you choose this location? 2.Is your haunted house “real” in the sense that it is a real home where people once lived? Or, was it made for the purpose of being a tourist attraction? Explain. 3.How many rooms of your haunted house will visitors be able to view? 4.Name and describe each of these rooms. Be as detailed as possible. 5.What does the outside of your haunted...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT