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
Fofino [41]
2 years ago
8

Given parameters b and h which stand for the base and the height of an isosceles triangle (i.e., a triangle that has two equal s

ides), write a C program that calculates: The area of the triangle; The perimeter of the triangle; And The volume of the cone formed by spinning the triangle around the line h The program must prompt the user to enter b and h (both of type double) The program must define and use the following three functions: Calc Area (base, height) //calculates and returns the area of the triangle Calc Perimeter (base, height) //calculates and returns the perimeter Calc Volume(base, height) //calculates and returns the volume
Computers and Technology
1 answer:
schepotkina [342]2 years ago
3 0

Answer:

The area of the triangle is calculated as thus:

Area = 0.5 * b * h

To calculate the perimeter of the triangle, the measurement of the slant height has to be derived;

Let s represent the slant height;

Dividing the triangle into 2 gives a right angled triangle;

The slant height, s is calculated using Pythagoras theorem as thus

s = \sqrt{b^2 + h^2}

The perimeter of the triangle is then calculated as thus;

Perimeter = s + s + b

Perimeter = \sqrt{b^2 + h^2} + \sqrt{b^2 + h^2} +b

Perimeter = 2\sqrt{b^2 + h^2} + b

For the volume of the cone,

when the triangle is spin, the base of the triangle forms the diameter of the cone;

Volume = \frac{1}{3} \pi * r^2 * h

Where r = \frac{1}{2} * diameter

So, r = \frac{1}{2}b

So, Volume = \frac{1}{3} \pi * (\frac{b}{2})^2 * h

Base on the above illustrations, the program is as follows;

#include<iostream>

#include<cmath>

using namespace std;

void CalcArea(double b, double h)

{

//Calculate Area

double Area = 0.5 * b * h;

//Print Area

cout<<"Area = "<<Area<<endl;

}

void CalcPerimeter(double b, double h)

{

//Calculate Perimeter

double Perimeter = 2 * sqrt(pow(h,2)+pow((0.5 * b),2)) + b;

//Print Perimeter

cout<<"Perimeter = "<<Perimeter<<endl;

}

void CalcVolume(double b, double h)

{

//Calculate Volume

double Volume = (1.0/3.0) * (22.0/7.0) * pow((0.5 * b),2) * h;

//Print Volume

cout<<"Volume = "<<Volume<<endl;

}

int main()

{

double b, h;

//Prompt User for input

cout<<"Base: ";

cin>>b;

cout<<"Height: ";

cin>>h;

//Call CalcVolume function

CalcVolume(b,h);

//Call CalcArea function

CalcArea(b,h);

//Call CalcPerimeter function

CalcPerimeter(b,h);

 

return 0;

}

You might be interested in
A search for reliable information is a search for what?
Nadusha1986 [10]

Answer:

For information you can trust

Explanation:

8 0
3 years ago
What parts of the computer does it not need to function?​
Thepotemich [5.8K]
Fancy lights, mouse, keyboard, you can do fan but the computer will eventually overheat, it need coolant for it to run for a long while
6 0
2 years ago
Create two classes. The first, named Sale, holds data for a sales transaction. Its private data members include the day of the m
olya-2409 [2.1K]

Answer:

A C++ program was used in creating two classes. the code is stated below.

Explanation:

Solution

The C++ program is executed below:

#include<iostream>

using namespace std;

//declare class (will be define later)

class Salesperson;

//class Sale

class Sale

{

  //private members of class

  private:

      string day;

      double amtOfSale;

      int salesPersonId;

 //public methods

  public:

      //constructor that takes day,amount of sale and salesPersonId as parameters

      Sale(string date,double sale,int id)

      {

          //set the private members to the initial values passed

          day=date;

          amtOfSale=sale;

          salesPersonId=id;

      }    

      //declare a friend function that takes objects of the two classes as parameters

      friend void display(Sale,Salesperson);

};  

//define class Salesperson

class Salesperson

{

  //private members of the class

  private:

      int salesPersonId;

      string lastName;    

  //public methods

  public:

      //constructor that takes name and id as parameters

      Salesperson(int id,string name)

      {

          //set the members of the class with the parameters passed

          salesPersonId=id;

          lastName=name;

      }  

      //declare a friend function that takes objects of the two classes as parameters

      friend void display(Sale,Salesperson);

};

//define the friend funtion

void display(Sale saleObj,Salesperson personObj)

{

  //display the sales info using the objects of the two classes

  cout<<"\nSale #"<<saleObj.salesPersonId<<" on "<<saleObj.day<<" for $"<<saleObj.amtOfSale<<" sold by #"<<personObj.salesPersonId<<" "<<personObj.lastName;

}  

int main()

{

  //create object for Sale class and pass default values

  Sale sObj1("12/25/2016",559.95,103);

  //create object for Salesperson class and pass default values

  Salesperson pObj1(103,"Woods");

 

  //create another object for Sale class and pass default values

  Sale sObj2("11/15/2016",359.95,106);

  //create another object for Salesperson class and pass default values

  Salesperson pObj2(106,"Hansen");

  //using the friend function dislay the sales info

  display(sObj1,pObj1);

  display(sObj2,pObj2);

  return 0;

}

4 0
3 years ago
What will the document.write() statement display, given the following code snippet? var scores = new Array[94, 90, 88, 82, 73, 7
astra-53 [7]

Answer:

There are 7 scores recorded. The dropped score is 75

Explanation:

The code snippet above prints through the document.write() function. the output prints the string serving as the argument, and makes use of variables (lgth) and expression also (scores [lgth -1]). what it does is. From the point where it sees +lgth+, it checks the value, which is 7. And when it sees scores [lgth-1] it evaluates it to 75. Hence, the string above is produced.

4 0
3 years ago
~ I already know this ~ who was the bits victim in five nights at freddys 4 <br> ___10 points___
Andreas93 [3]

Answer:

i dont know anything about them only that the bear is the ducks son and the duck is the fox mom.

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which of these is a weakness of written communication?
    8·1 answer
  • To insert a new slide in an existing presentation, what menu should you select?
    5·2 answers
  • In cell R9, enter a formula using the AVERAGEIF function to determine the average number of years of experience for lifeguards.
    12·1 answer
  • The Change Speed command in Audacity lets you change which two things about a track at the same time?
    9·1 answer
  • Which is the best description of the difference between bound and unbound forms? O Bound forms are similar to hierarchical forms
    7·1 answer
  • Given an array as follows
    11·1 answer
  • Which of the following laptop features allows users to overcome keyboard size restrictions?
    11·1 answer
  • A range check that can be used in Microsoft access to calculate the data collected which is date and time
    10·1 answer
  • This finding maximum number function will keep on going until we reach at the last value
    12·1 answer
  • You Could Never Size Me UP! Been Doing This Sh*t A Long ⏱time
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!