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
igomit [66]
3 years ago
10

More discussion about seriesConnect(Ohm) function In your main(), first, construct the first circuit object, called ckt1, using

the class defined above. Use a loop to call setOneResistance() function to populate several resistors. Repeat the process for another circuit called ckt2. Develop a member function called seriesConnect() such that ckt2 can be connected to ckt1 using instruction ckt1.seriesConnect(ckt2).
Engineering
1 answer:
STALIN [3.7K]3 years ago
8 0

Answer:

resistor.h

//circuit class template

#ifndef TEST_H

#define TEST_H

#include<iostream>

#include<string>

#include<vector>

#include<cstdlib>

#include<ctime>

#include<cmath>

using namespace std;

//Node for a resistor

struct node {

  string name;

  double resistance;

  double voltage_across;

  double power_across;

};

//Create a class Ohms

class Ohms {

//Attributes of class

private:

  vector<node> resistors;

  double voltage;

  double current;

//Member functions

public:

  //Default constructor

  Ohms();

  //Parameterized constructor

  Ohms(double);

  //Mutator for volatage

  void setVoltage(double);

  //Set a resistance

  bool setOneResistance(string, double);

  //Accessor for voltage

  double getVoltage();

  //Accessor for current

  double getCurrent();

  //Accessor for a resistor

  vector<node> getNode();

  //Sum of resistance

  double sumResist();

  //Calculate current

  bool calcCurrent();

  //Calculate voltage across

  bool calcVoltageAcross();

  //Calculate power across

  bool calcPowerAcross();

  //Calculate total power

  double calcTotalPower();

  //Display total

  void displayTotal();

  //Series connect check

  bool seriesConnect(Ohms);

  //Series connect check

  bool seriesConnect(vector<Ohms>&);

  //Overload operator

  bool operator<(Ohms);

};

#endif // !TEST_H

resistor.cpp

//Implementation of resistor.h

#include "resistor.h"

//Default constructor,set voltage 0

Ohms::Ohms() {

  voltage = 0;

}

//Parameterized constructor, set voltage as passed voltage

Ohms::Ohms(double volt) {

  voltage = volt;

}

//Mutator for volatage,set voltage as passed voltage

void Ohms::setVoltage(double volt) {

  voltage = volt;

}

//Set a resistance

bool Ohms::setOneResistance(string name, double resistance) {

  if (resistance <= 0){

      return false;

  }

  node n;

  n.name = name;

  n.resistance = resistance;

  resistors.push_back(n);

  return true;

}

//Accessor for voltage

double Ohms::getVoltage() {

  return voltage;

}

//Accessor for current

double Ohms::getCurrent() {

  return current;

}

//Accessor for a resistor

vector<node> Ohms::getNode() {

  return resistors;

}

//Sum of resistance

double Ohms::sumResist() {

  double total = 0;

  for (int i = 0; i < resistors.size(); i++) {

      total += resistors[i].resistance;

  }

  return total;

}

//Calculate current

bool Ohms::calcCurrent() {

  if (voltage <= 0 || resistors.size() == 0) {

      return false;

  }

  current = voltage / sumResist();

  return true;

}

//Calculate voltage across

bool Ohms::calcVoltageAcross() {

  if (voltage <= 0 || resistors.size() == 0) {

      return false;

  }

  double voltAcross = 0;

  for (int i = 0; i < resistors.size(); i++) {

      voltAcross += resistors[i].voltage_across;

  }

  return true;

}

//Calculate power across

bool Ohms::calcPowerAcross() {

  if (voltage <= 0 || resistors.size() == 0) {

      return false;

  }

  double powerAcross = 0;

  for (int i = 0; i < resistors.size(); i++) {

      powerAcross += resistors[i].power_across;

  }

  return true;

}

//Calculate total power

double Ohms::calcTotalPower() {

  calcCurrent();

  return voltage * current;

}

//Display total

void Ohms::displayTotal() {

  for (int i = 0; i < resistors.size(); i++) {

      cout << "ResistorName: " << resistors[i].name << ", Resistance: " << resistors[i].resistance

          << ", Voltage_Across: " << resistors[i].voltage_across << ", Power_Across: " << resistors[i].power_across << endl;

  }

}

//Series connect check

bool Ohms::seriesConnect(Ohms ohms) {

  if (ohms.getNode().size() == 0) {

      return false;

  }

  vector<node> temp = ohms.getNode();

  for (int i = 0; i < temp.size(); i++) {

      this->resistors.push_back(temp[i]);

  }

  return true;

}

//Series connect check

bool Ohms::seriesConnect(vector<Ohms>&ohms) {

  if (ohms.size() == 0) {

      return false;

  }

  for (int i = 0; i < ohms.size(); i++) {

      this->seriesConnect(ohms[i]);

  }

  return true;

}

//Overload operator

bool Ohms::operator<(Ohms ohms) {

  if (ohms.getNode().size() == 0) {

      return false;

  }

  if (this->sumResist() < ohms.sumResist()) {

      return true;

  }

  return false;

}

main.cpp

#include "resistor.h"

int main()

{

   //Set circuit voltage

  Ohms ckt1(100);

  //Loop to set resistors in circuit

  int i = 0;

  string name;

  double resistance;

  while (i < 3) {

      cout << "Enter resistor name: ";

      cin >> name;

      cout << "Enter resistance of circuit: ";

      cin >> resistance;

      //Set one resistance

      ckt1.setOneResistance(name, resistance);

      cin.ignore();

      i++;

  }

  //calculate totalpower and power consumption

  cout << "Total power consumption = " << ckt1.calcTotalPower() << endl;

  return 0;

}

Output

Enter resistor name: R1

Enter resistance of circuit: 2.5

Enter resistor name: R2

Enter resistance of circuit: 1.6

Enter resistor name: R3

Enter resistance of circuit: 1.2

Total power consumption = 1886.79

Explanation:

Note

Please add all member function details.Its difficult to figure out what each function meant to be.

You might be interested in
A piston-cylinder assembly has initially a volume of 0.3 m3 of air at 25 °C. Mass of the air is 1 kg. Weights are put on the pis
kogti [31]

Answer:

n=2.32

w= -213.9 KW

Explanation:

V_1=0.3m^3,T_1=298 K

V_2=0.1m^3,T_1=1273 K

Mass of air=1 kg

For polytropic process  pv^n=C ,n is the polytropic constant.

  Tv^{n-1}=C

  T_1v^{n-1}_1=T_2v^{n-1}_2

298\times .3^{n-1}_1=1273\times .1^{n-1}_2

n=2.32

Work in polytropic process given as

       w=\dfrac{P_1V_1-P_2V_2}{n-1}

      w=mR\dfrac{T_1-T_2}{n-1}

Now by putting the values

w=1\times 0.287\dfrac{289-1273}{2.32-1}

w= -213.9 KW

Negative sign indicates that work is given to the system or work is done on the system.

For T_V diagram

  We can easily observe that when piston cylinder reach on new position then volume reduces and temperature increases,so we can say that this is compression process.

5 0
3 years ago
Design for human-fit strategies include:
andreev551 [17]

Answer:

B- extreme fit, close fit, adjustable fit

Explanation:

A human-fit design typically involves the process of manufacturing or producing products (tools) that are easy to use by the end users. Therefore, human-fit designs mainly deals with creating ideas that makes the use of a particular product comfortable and convenient for the end users.

The design for human-fit strategies include; extreme fit, close fit and adjustable fit.

Hence, when the aforementioned strategies are properly integrated into a design process, it helps to ensure the ease of use of products and guarantees comfort for the end users.

5 0
2 years ago
The aluminum rod (E1 = 68 GPa) is reinforced with the firmly bonded steel tube (E2 = 201 GPa). The diameter of the aluminum rod
Vsevolod [243]

Answer:

Explanation:

From the information given:

E_1 = 68 \ GPa \\ \\ E_2 = 201 \ GPa  \\ \\ d = 25 \ mm \  \\ \\ D = 45 \ mm \ \\ \\ L   = 761 \ mm  \\ \\ P = -88 kN

The total load is distributed across both the rod and tube:

P = P_1+P_2 --- (1)

Since this is a composite column; the elongation of both aluminum rod & steel tube is equal.

\delta_1=\delta_2

\dfrac{P_1L}{A_1E_1}= \dfrac{P_2L}{A_2E_2}

\dfrac{P_1 \times 0.761}{(\dfrac{\pi}{4}\times .0025^2 ) \times 68\times 10^4}= \dfrac{P_2\times 0.761}{(\dfrac{\pi}{4}\times (0.045^2-0.025^2))\times 201 \times 10^9}

P_1(2.27984775\times 10^{-8}) = P_2(3.44326686\times 10^{-9})

P_2 = \dfrac{ (2.27984775\times 10^{-8}) P_1}{(3.44326686\times 10^{-9})}

P_2 = 6.6212 \ P_1

Replace P_2 into equation (1)

P= P_1 + 6.6212 \ P_1\\ \\ P= 7.6212\ P_1 \\ \\  -88 = 7.6212 \ P_1  \\ \\ P_1 = \dfrac{-88}{7.6212} \\ \\  P_1 = -11.547 \ kN

Finally, to determine the normal stress in aluminum rod:

\sigma _1 = \dfrac{P_1}{A_1} \\ \\  \sigma _1 = \dfrac{-11.547 \times 10^3}{\dfrac{\pi}{4} \times 25^2}

\sigma_1 = - 23.523 \ MPa}

Thus, the normal stress = 23.523 MPa in compression.

8 0
3 years ago
Calculate the wire pressure for a round copper bar with an original cross-sectional area of 12.56 mm2 to a 30% reduction of area
dybincka [34]

Answer:153.76 MPa

Explanation:

Initial Area\left ( A_0\right )=12.56 mm^2

Final Area\left ( A_f\right )=0.7\times 12.56 mm^2=8.792 mm^2

Die angle=30^{\circ}

\alpha =\frac{30}{2}=15^{\circ}

\mu =0.08

Yield stress\left ( \sigma _y \right )=350 MPa

B=\mu cot\left ( \aplha\right )=0.2985

\sigma _{pressure}=\sigma _y\left [\frac{1+B}{B}\right ]\left [ 1-\frac{A_f}{A_0}\right ]^B

\sigma _{pressure}=350\left [\frac{1+0.2985}{0.2985}\right ]\left [ 1-\frac{8.792}{12.56}\right ]^{0.2985}

\sigma _{pressure}=153.76 MPa

8 0
3 years ago
Explain the prosses of welding
klio [65]

Answer:

Welding is a fabrication process whereby two or more parts are fused together by means of heat, pressure or both forming a join as the parts cool. Welding is usually used on metals and thermoplastics but can also be used on wood.

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • Signal generator‘s internal impedance is purely resistive and has an open-circuit voltage of 3.5 V. When the generator is loaded
    11·1 answer
  • Name 3 ways in which robots have improved since the Ebola outbreak.
    11·1 answer
  • What is 29*69+98-78/36=
    9·2 answers
  • Consider two different types of motors. Motor A has a characteristic life of 4100 hours (based on a MTTF of 4650 hours) and a sh
    10·1 answer
  • The crash rate per mile is.
    15·1 answer
  • Compute the volume percent of graphite, VGr, in a 2.5 wt% C cast iron, assuming that all the carbon exists as the graphite phase
    9·1 answer
  • Please please help please with this this is the link for the story PLEASE PLEASE HELP PLEASE PLEASE help please
    7·1 answer
  • Consider the following example: The 28-day compressive strength should be 4,000 psi. The slump should be between 3 and 4 in. and
    13·1 answer
  • What could I do to make this bridge hold more weight without making it heavier? Lateral bracing and a design on the top will be
    14·1 answer
  • Two technicians are discussing torsion bars. Technician A says that many torsion bars are adjustable to allow for ride height ad
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!