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
The AGC control voltage: ___________
lyudmila [28]

Answer:

The AGC circuit operates with an input voltage range of 60 dB (5 mV p-p to 5 V p-p), with a fixed output voltage of 250 mV p-p.

Explanation:

3 0
2 years ago
A compound sliding miter saw can be used to make
Sunny_sXe [5.5K]

Answer:

D

Explanation:

3 0
2 years ago
What is chemical engineering​
viktelen [127]

Answer:

Chemical engineering is the branch of engineering that deals with chemical production and the manufacture of products through chemical processes

Explanation:

8 0
3 years ago
A sandy soil has a total unit weight of 120 pcf, a specific gravity of solids of 2.64, and a water content of 16 percent. Comput
olchik [2.2K]

Answer:

A). Dry unit weight = 1657.08Kg/m3

B). Porosity  = 0.37

C). Void ratio  = 0.593 

D). 0.712

Explanation:

Total unit weight, Y = 120pcf =1922.2 Kg/m3

Specific gravity of solids, Gs = 2.64

Water content, w = 16%

A). Dry unit weight

Yd = Y/(1+w)

= 1922.2/(1+0.16) = 1657.08Kg/m3

B). Porosity

However void ratio, e = Gs×Yw/Yd, where Yw = 1000Kg/m3

Void ratio = 2.64×1000/1657.08 = 0.593

 

And porosity = e/(1+e) =0.593/(1+0.593) = 0.37

C). void ratio, e = 0.593

D). Degree of saturation, S = m×Gs/e where m =water content

S = 0.16×2.64/0.593 = 0.712

5 0
3 years ago
What is the thermal efficiency of a gas power cycle using thermal energy reservoirs at 627°C and 60°C? The thermal efficiency is
Vesna [10]

Answer

63 %

Explanation:

It is given that the reservoirs is at the temperature of 627°C and 27°C

So lower temperature that isT_L  = 60°C=273+60=333 K

And the higher temperature that is T_H  = 627°C =273+627=900 K

We know that the thermal efficiency of thermal reservoir = 1-\frac{T_L}{T_H}  = 1-\frac{333}{900} = 0.63 =63 %

So the efficiency of the reservoir is 63%

3 0
3 years ago
Other questions:
  • Write a SELECT statement that returns the same result set as this SELECT statement. Substitute a subquery in a WHERE clause for
    10·1 answer
  • In the contemporary approach to control systems, benefits of continuous monitoring include which one of the following? Multiple
    9·1 answer
  • suppose we number the bytes in a w-bit word from 0 (less significant) to w/8-1 (most significant). write code for the followign
    11·1 answer
  • Rosalind franklin<br> What was she famous for
    14·1 answer
  • What would be the most likely scale factor to use for an n-gauge model train setup? (An n-gauge layout uses locomotives that are
    8·1 answer
  • Is an ideal way for a high school student to see what an engineer does on a typical day but does not provide a hands-on experien
    9·2 answers
  • 1. Differentiate between speed and velocity.<br>​
    9·2 answers
  • Cual es el costo del kwh
    8·1 answer
  • Who invented engineering first?​
    12·1 answer
  • Identify the prefixes used in the International System of
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!