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
Consider a N-channel enhancement MOSFET with VGS = 3V, Vt = 1 V, VDS = 10 V, and lambda =0 (channel length modulation parameter)
AveGali [126]

The current IDS is greater than 0 since the VGS has induced an inversion layer and the transistor is operating in the saturation region.

<u>Explanation:</u>

  • Since V_{ds} > V_{gs} - Vt because V_{gs} > Vt.
  • By the saturation region the MOSFET is operating.
  • A specific source voltage and gate of NMOS, the voltage get drained during the specific level, the drain voltage is rises beyond where there is no effect of current during saturated region.
  • MOSFET is a transistor which is a device of semiconductor vastly used for the electronic amplifying signals and switching in the devices of electronics.
  • The core of this is integrated circuit.
  • It is fabricated and designed in an individual chips due to tiny sizes.
7 0
3 years ago
An inventor claims to have devised a cyclical power engine that operates with a fuel whose temperature is 750 °C and radiates wa
Phantasy [73]

Answer:

Yes

Explanation:

Given Data

Temprature of source=750°c=1023k

Temprature of sink =0°c=273k

Work produced=3.3KW

Heat Rejected=4.4KW

Efficiency of heat engine(η)=\frac{Work produced}{Heat supplied}

and

Heat Supplied {\left (Q_s\right)}=Work Produced(W)+Heat rejected\left ( Q_r \right )

{Q_s}=3.3+4.4=7.7KW

η=\frac{3.3}{7.7}

η=42.85%

Also the maximum efficiency of a heat engine operating between two different Tempratures i.e. Source & Sink

η=1-\frac{T_ {sink}}{T_ {source}}

η=1-\frac{273}{1023}

η=73.31%

Therefore our Engine Efficiency is less than the maximum efficiency hence the given claim is valid.

5 0
3 years ago
HELP PLEASE
Sveta_85 [38]

..........23÷357=0.0644257703........

8 0
2 years ago
a(n) cycle is the complete operating sequence of a water closet, urinal, or similar device or fixture.
Lady bird [3.3K]

According to plumbing regulations, every home must have a minimum of one toilet, one bathroom sink, one bathtub or shower, and one kitchen sink. Fixtures include items like these and a few more things mentioned in this chapter.

When choosing fixtures, consider flow rates, volume, and water usage. Water saving is a major concern of plumbing sustainability. Two key areas for water conservation are shower heads and bathroom faucets. The length of each use determines how much water is actually saved when taking a shower. A handheld shower may have controls that allow the water flow to be turned off while performing specific showering tasks, including lathering.

Learn more about fixtures here:

brainly.com/question/28430942

#SPJ4

5 0
1 year ago
An aluminum alloy [E = 73 GPa] cylinder (2) is held snugly between a rigid plate and a foundation by two steel bolts (1) [E = 18
V125BC [204]

Answer:

\sigma_A = 58.43 N/mm^2

Explanation:

Given data:

length of Steel bolt L_1 = 335 mm

Length of aluminium cylinder L_2 = 275 mm

Pitch of bolt p = 1mm

Modulus of elasticity of steel E = 215 GPa

Modulus of elasticity of aluminium =  74 GP

Area of bolt = \frac{\pi}{4} 14^2 =  153.93 mm^2

Area of cylinder  = 2300 mm^2

n =1

By equilibrium

\sum F_y = 0

P_A -2P_S = 0

P_A =2P_S

By the compatibility

\delta _s + \delta_A = nP

Displacement in steel is \delta_s = \frac{P_sL_s}{E_sA_s}

Displacement in Aluminium is \delta_A = \frac{P_AL_A}{E_AA_A}

from compatibility equation we have

\frac{P_sL_s}{E_sA_s} +  \frac{P_AL_A}{E_AA_A} = nP

\frac{P_s\times 335}{180\times 10^3\times 153.93} +  \frac{P_A\times 275}{73\times 10^3\times 2300} = 1\times 1

1.20\times 10^[-5} P_s  + 1.44\times 10^{-6}P_A = 1

substituteP_A =2P_S

1.20\times 10^[-5} P_s  + 1.44\times 10^{-6} (2\times P_s) = 1

1.488\times 10^{-5} P_s = 1

P_s = 67204.30 N

P_A = 134,408.60 N

Stress in Aluminium \sigma  = \frac{P_A}{A_A}

                                               = \frac{134,408.60}{2300}

                             \sigma_A = 58.43 N/mm^2

8 0
3 years ago
Other questions:
  • The purification of hydrogen gas is possible by diffusion through a thin palladium sheet. Calculate the number of kilograms of h
    15·1 answer
  • 500 flights land each day at San Jose’s airport. Assume that each flight has a 5% chance of being late, independently of whether
    5·1 answer
  • Suppose that the time (in hours) required to repair a machine is an exponentially distributed random variable with parameter ???
    13·1 answer
  • All of the following are categories for clutch covers except
    11·1 answer
  • what is the expected life 1 inch diameter bar machined from AISI 1020 CD Steel is subjected to alternating bending stress betwee
    9·1 answer
  • Trees grow in bulk in outward direction​
    9·1 answer
  • Writing an excellent problem statement will not help guide you through the rest of the process and steer you towards the BEST so
    8·1 answer
  • Question in image. Question from OSHA.
    11·2 answers
  • This might count as engineering, I'm not sure as this is IT
    8·1 answer
  • Recall the steps of the engineering design process. Compare and contrast the
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!