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
slega [8]
3 years ago
15

Write a program to calculate the area of circle, rectangle using a class. The program would prompt a user to select (1) circle o

r (2) rectangle followed by asking the necessary dimensions. Once the user enters the valid input, the program then calculates the area and prints the final value. The set()/get() methods must include data validation.
Engineering
1 answer:
cricket20 [7]3 years ago
3 0

Answer:

The following program written in c++:

#include <iostream>

using namespace std;

class Circle   //define class

{

private :      //access modifier

double pi, radius, area;    // set double type variables

public :

Circle (double radius = 0.0)    //define constructor

{

pi = 3.1415;

this->radius = radius;

}

void setRadius (double radius)     // define void type method

{

if (radius < 0){      // if the radius is negative don't take it

cout << "Radius can't be negative." << endl;

return;

}

this->radius = radius;

}

double getArea ()        // define double type method

{

area = pi * radius * radius;

return area;

}

};

class Rectangle      //define class

{

private:       //access modifier

double length ,breadth ,area; // set double type private data types

public:

Rectangle (double length = 0.0, double breadth = 0.0) // define constructor

{

this->length = length;

this->breadth = breadth;

}

void setDimension (double length , double breadth ) // define void type method

{

if (length < 0 || breadth < 0){ //set if condition, if the dimensions is negative than don't take it

cout << "Dimensions can't be negative." << endl;

return;

}

this->length = length;

this->breadth = breadth;

}

double getArea ()      // define double type method

{

area = length * breadth;

return area;

}

};

int main()      //main function

{

int choice;      //integer type variable

double radius, length, breadth;

Circle c;

Rectangle r;

cout << "Select ( 1 ) Circle or select ( 2 ) Rectangle : "; // get the choice of user

cin >> choice;

switch (choice)

{

case 1 : cout << "Enter radius of circle : ";

cin >> radius;

c.setRadius(radius);

cout << "Area of circle is : " << c.getArea();

break;

case 2 : cout << "Enter dimensions of rectangle : ";

cin >> length >> breadth;

r.setDimension(length,breadth);

cout << "Area of rectangle is : " << r.getArea();

break;

default : cout << "Invalid Selection...";

}

return 0;

}

Explanation:

Here, we define two classes "Circle" and "Rectangle"

Then, we create first two function which get the value from the user.

Then, we create the second two functions which return the calculation of the following formulas.

You might be interested in
A large well-mixed tank of unknown volume, open to the atmosphere initially, contains pure water. The initial height of the solu
trasher [3.6K]

Answer:

The exact time when the sample was taken is = 0.4167337 hr

Explanation:

The diagram of a sketch of the tank is shown on the first uploaded image

Let A denote the  first inlet

Let B denote the second inlet

Let C denote the single outflow from the tank

From the question we are given that the diameter of A is = 1 cm = 0.01 m

                              Area of  A is  = \frac{\pi}{4}(0.01)^{2} m^{2}

                                                    = 7.85 *10^{-5}m^{2}

Velocity of liquid through A = 0.2 m/s

  The rate at which the liquid would flow through the first inlet in terms of volume  = \frac{Volume of Inlet }{time} = Velocity * Area i.e is m^{2} * \frac{m}{s}   = \frac{m^{3}}{s}

             = 0.2 *7.85*10^{-5} \frac{m^{3}}{s}

  The rate at which the liquid would flow through the first inlet in terms of mass of the liquid = mass of liquid × the rate of flow in terms of volume

                              =  1039.8 * 0.2 * 7.85 *10^{-5} Kg/s

                              = 0.016324 \frac{Kg}{s}

From the question the diameter of B = 2 cm = 0.02 m

                                           Area of B = \frac{\pi}{4} * (0.02)^{2} m^{2} = 3.14 * 10^{-4}m^{2}

                                     Velocity of liquid through B = 0.01 m/s

The rate at which the liquid would flow through the first inlet in terms of volume  = \frac{Volume of Inlet }{time} = Velocity * Area i.e is m^{2} * \frac{m}{s}   = \frac{m^{3}}{s}

             = 3.14*10^{-4} *0.01 \frac{m^{3}}{s}

The rate at which the liquid would flow through the second inlet in terms of mass of the liquid = mass of liquid × the rate of flow in terms of volume

                              = 1053 * 3.14*10^{-6} \frac{Kg}{s}

                              = 0.00330642 \frac{Kg}{s}

From the question The flow rate in term of volume of the outflow at the time of measurement is given as  = 0.5 L/s

And also from the question the mass of  potassium chloride  at the time of measurement is given as 13 g/L

So The rate at which the liquid would flow through the outflow in terms of mass of the liquid = mass of liquid × the rate of flow in terms of volume

                              = 13\frac{g}{L} * 0.5 \frac{L}{s}

                              =  \frac{6.5}{1000}\frac{Kg}{s}       Note (1 Kg = 1000 g)

                              = 0.0065 kg/s

Considering potassium chloride

         Let denote the  rate at which liquid flows in terms of mass as   as \frac{dm}{dt} i.e change in mass with respect to time hence

           Input(in terms of mass flow ) - output(in terms of mass flow ) = Accumulation in the Tank(in terms of mass flow )

         

      (0.016324 + 0.00330642) - 0.0065 = \frac{dm}{dt}

          \int\limits {\frac{dm}{dt} } \, dx  =\int\limits {0.01313122} \, dx

      => 0.01313122 t = (m - m_{o})

  From the question  (m - m_{o})  is given as = 19.7 Kg

Hence the time when the sample was taken is given as

               0.01313122 t = 19.7 Kg

      =>  t = 1500.2414 sec

            t = .4167337 hours (1 hour = 3600 seconds)

5 0
4 years ago
1. When should a synthetic oil change be completed? *
Roman55 [17]

Answer:

A range from 5,000 miles to 7,500 miles, on average. Some recommended intervals may be shorter or longer.

4 0
3 years ago
Read 2 more answers
Solid Isomorphous alloys strength
adell [148]
Lol please give me points
5 0
3 years ago
A counter-flow double-piped heat exchange is to heat water from 20oC to 80oC at a rate of 1.2 kg/s. The heating is to be accompl
lawyer [7]

Answer:

110 m or 11,000 cm

Explanation:

  • let mass flow rate for cold and hot fluid = M<em>c</em> and M<em>h</em> respectively
  • let specific heat for cold and hot fluid = C<em>pc</em> and C<em>ph </em>respectively
  • let heat capacity rate for cold and hot fluid = C<em>c</em> and C<em>h </em>respectively

M<em>c</em> = 1.2 kg/s and M<em>h = </em>2 kg/s

C<em>pc</em> = 4.18 kj/kg °c and C<em>ph</em> = 4.31 kj/kg °c

<u>Using effectiveness-NUT method</u>

  1. <em>First, we need to determine heat capacity rate for cold and hot fluid, and determine the dimensionless heat capacity rate</em>

C<em>c</em> = M<em>c</em> × C<em>pc</em> = 1.2 kg/s  × 4.18 kj/kg °c = 5.016 kW/°c

C<em>h = </em>M<em>h</em> × C<em>ph </em>= 2 kg/s  × 4.31 kj/kg °c = 8.62 kW/°c

From the result above cold fluid heat capacity rate is smaller

Dimensionless heat capacity rate, C = minimum capacity/maximum capacity

C= C<em>min</em>/C<em>max</em>

C = 5.016/8.62 = 0.582

          .<em>2 Second, we determine the maximum heat transfer rate, Qmax</em>

Q<em>max</em> = C<em>min </em>(Inlet Temp. of hot fluid - Inlet Temp. of cold fluid)

Q<em>max</em> = (5.016 kW/°c)(160 - 20) °c

Q<em>max</em> = (5.016 kW/°c)(140) °c = 702.24 kW

          .<em>3 Third, we determine the actual heat transfer rate, Q</em>

Q = C<em>min (</em>outlet Temp. of cold fluid - inlet Temp. of cold fluid)

Q = (5.016 kW/°c)(80 - 20) °c

Q<em>max</em> = (5.016 kW/°c)(60) °c = 303.66 kW

            .<em>4 Fourth, we determine Effectiveness of the heat exchanger, </em>ε

ε<em> </em>= Q/Qmax

ε <em>= </em>303.66 kW/702.24 kW

ε = 0.432

           .<em>5 Fifth, using appropriate  effective relation for double pipe counter flow to determine NTU for the heat exchanger</em>

NTU = \\ \frac{1}{C-1} ln(\frac{ε-1}{εc -1} )

NTU = \frac{1}{0.582-1} ln(\frac{0.432 -1}{0.432 X 0.582   -1} )

NTU = 0.661

          <em>.6 sixth, we determine Heat Exchanger surface area, As</em>

From the question, the overall heat transfer coefficient U = 640 W/m²

As = \frac{NTU C{min} }{U}

As = \frac{0.661 x 5016 W. °c }{640 W/m²}

As = 5.18 m²

            <em>.7 Finally, we determine the length of the heat exchanger, L</em>

L = \frac{As}{\pi D}

L = \frac{5.18 m² }{\pi (0.015 m)}

L= 109.91 m

L ≅ 110 m = 11,000 cm

3 0
3 years ago
Savabuck University has installed standard pressure-operated flush valves on their water closets. When flushing, these valves de
Dvinal [7]

Answer:

Cost = $2527.2 per month.

Explanation:

Given that

Discharge ,Q = 130 L/min

 So

Q=0.13\ m^3/min

Cost =  $0.45 per cubic meter

1 month = 30 days

1 days = 24 hr = 24 x 60 min

1 month = 30 x 24 x 60 min

1 month = 43,200 min

Lets xm^3\ water\ waste\ in\ a\ month

x = 0.13 x 43,200

x=5616\ m^3

So the total cost = 5616 x 045 $

Cost = $2527.2 per month.

7 0
4 years ago
Other questions:
  • Air is drawn from the atmosphere into a turbomachine. At the exit, conditions are 500 kPa (gage) and 130oC. The exit speed is 10
    8·1 answer
  • A turbine operates at steady state, and experiences a heat loss. 1.1 kg/s of water flows through the system. The inlet is mainta
    6·1 answer
  • A 10-m long steel linkage is to be designed so that it can transmit 2 kN of force without stretching more than 5 mm nor having a
    9·1 answer
  • Bob and Alice are solving practice problems for CSE 2320. They look at this code: for(i = 1; i &lt;= N; i = (i*2)+17 ) for(k = i
    6·2 answers
  • What are the four essential components of a UAS?
    12·1 answer
  • Guess my birthday it’s in September you should be good with it
    6·1 answer
  • A crawler crane has two tracks each sits on a patch of ground 15 feet long by 2 feet wide what is the area of ground that is in
    9·1 answer
  • Explain jack plane. please dont copy from go ogle<br>​
    15·2 answers
  • Explain your own understanding about the relevant connections between the four subsystems of Earth through the use of a creative
    9·1 answer
  • Which two measurements are needed in order to calculate the speed of an object in
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!