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
Do plastic materials have high or low ductility? Explain why.​
Flura [38]
The impact behavior of plastic materials is strongly dependent upon the temperature. At high temperatures, materials are more ductile and have high impact toughness. At low temperatures, some plastics that would be ductile at room temperature become brittle.
3 0
2 years ago
Sawing stock to reduce its thickness is known as __________ .
rjkz [21]

Answer:

resawing

Explanation:

8 0
3 years ago
I have to find the critical points of this function of two variables <img src="https://tex.z-dn.net/?f=%5C%5Cf%28x%2Cy%29%3Dx%5E
liraira [26]

Answer:

no i dont think there is

Explanation:

because theres not

4 0
3 years ago
Which of the following is NOT a provision of the Agricultural Adjustment Act? insurance for farmers alternative energy programs
Arisa [49]

Answer:

Farm equipment

Explanation:

Most people have heard claims that the US government pays farmers not to grow crops. The Agricultural Adjustment Act is the legislation that started this program. It was the first “Farm Bill.” The current farm bill provides for the following:

Subsidies for farmers

Insurance for farmers

Price supports

Food assistance for economically challenged Americans (the largest portion of the Farm Bill)

Forestry conservation programs

Alternative energy programs.

4 0
3 years ago
A well-insulated rigid vessel contains 3 kg of saturated liquid water at 40oC. The vessel also contains an electrical resistor t
user100 [1]

Answer:

The final temperature is 111.66°C

Explanation:

The given conditions :-

i) Well insulated means no heat loss.

ii) Rigid vessels means volume remains same.

iii) Initial temperature ( T₁ ) = 40°C. = 273 + 40 = 313 K

iv ) Mass of water in vessel = 3 kg.

v) current drawn by resistor ( i ) = 10 ampere.

vi) Voltage applied ( V ) = 50 volts.

vii) The time for which resistor operating ( t ) = 30 minute = 30 * 60 = 1800 seconds.

Now we have to calculate heat developed by resistor in vessel.

Q = V * i * t  = 50 * 10 * 1800 = 900,000 J = 900 KJ.

Since it is a rigid container so the work done is zero.

Q = du    ( du - change in internal energy)

Q = m * C * dT      ( C = 4.186 KJ/KgK )

Q = 3 * 4.186 * (T₂ - T₁ )

900 = 12.558 * ( T₂ - 313 )

T₂ - 313 = 71.6674

T₂ = 384.6674 K

T = 384.6674 - 273 = 111.66°C

So the final temperature is 111.66°C.

3 0
3 years ago
Other questions:
  • Water flows through a horizontal plastic pipe with a diameter of 0.15 m at a velocity of 15 cm/s. Determine the pressure drop pe
    11·1 answer
  • Technician A says that when the malfunction indicator light or service engine light is on you should retrieve the diagnostic tro
    10·1 answer
  • Refrigerant-134a enters a diffuser steadily as saturated vapor at 600 kPa with a velocity of 160 m/s, and it leaves at 700 kPa a
    10·2 answers
  • Two AAA-size lithium batteries are connected in series in a flashlight. Each battery has 3.5 volt and 4- Amp-hour capacity. If t
    8·1 answer
  • The dam cross section is an equilateral triangle, with a side length, L, of 50 m. Its width into the paper, b, is 100 m. The dam
    9·1 answer
  • A completely reversible heat pump produces heat ata rate of 300 kW to warm a house maintained at 24°C. Theexterior air, which is
    6·1 answer
  • 7. The "3 second rule" is the time you should pause at an intersection marked with a stop sign.
    6·1 answer
  • Proper ventilation is required when welding, so that you don't ____________.
    14·2 answers
  • ____________ is the organization that oversees environmental compliance.
    14·1 answer
  • Me ayudas plis noce ​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!