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 rapid sand filter has a loading rate of 8.00 m/h, surface dimensions of 10 m ´ 8 m, an effective filtration rate of 7.70 m/h.
galben [10]

Answer:

Explanation:

given data

loading rate = 8.00 m/h

filtration rate = 7.70 m/h

dimensions = 10 m × 8 m

filter cycle duration = 52 h

time = 20 min

to find out

flow rate  and  volume of water is used for back washing plus rinsing the filter  

solution  

we consider here production efficiency is 96%

so here flow rate will be  

flow rate = area × rate of filtration  

flow rate = 10 × 8 × 7.7  

flow rate = 616 m³/h

and  

we know back washing generally 3 to 5 % of total volume of water per cycle so  

volume of water is = 616 × 52

volume of water is  32032 m³

and  

volume of water of back washing is = 4% of 32032  

volume of water of back washing is 1281.2 m³

8 0
4 years ago
A long aluminum wire of diameter 3 mm is extruded at a temperature of 280°C. The wire is subjected to cross air flow at 20°C at
Musya8 [376]

Answer:

Explanation:

Given:

Diameter of aluminum wire, D = 3mm

Temperature of aluminum wire, T_{s}=280^{o}C

Temperature of air, T_{\infinity}=20^{o}C

Velocity of air flow V=5.5m/s

The film temperature is determined as:

T_{f}=\frac{T_{s}-T_{\infinity}}{2}\\\\=\frac{280-20}{2}\\\\=150^{o}C

from the table, properties of air at 1 atm pressure

At T_{f}=150^{o}C

Thermal conductivity, K = 0.03443 W/m^oC; kinematic viscosity v=2.860 \times 10^{-5} m^2/s; Prandtl number Pr=0.70275

The reynolds number for the flow is determined as:

Re=\frac{VD}{v}\\\\=\frac{5.5 \times(3\times10^{-3})}{2.86\times10^{-5}}\\\\=576.92

sice the obtained reynolds number is less than 2\times10^5, the flow is said to be laminar.

The nusselt number is determined from the relation given by:

Nu_{cyl}= 0.3 + \frac{0.62Re^{0.5}Pr^{\frac{1}{3}}}{[1+(\frac{0.4}{Pr})^{\frac{2}{3}}]^{\frac{1}{4}}}[1+(\frac{Re}{282000})^{\frac{5}{8}}]^{\frac{4}{5}}

Nu_{cyl}= 0.3 + \frac{0.62(576.92)^{0.5}(0.70275)^{\frac{1}{3}}}{[1+(\frac{0.4}{(0.70275)})^{\frac{2}{3}}]^{\frac{1}{4}}}[1+(\frac{576.92}{282000})^{\frac{5}{8}}]^{\frac{4}{5}}\\\\=12.11

The covective heat transfer coefficient is given by:

Nu_{cyl}=\frac{hD}{k}

Rewrite and solve for h

h=\frac{Nu_{cyl}\timesk}{D}\\\\=\frac{12.11\times0.03443}{3\times10^{-3}}\\\\=138.98 W/m^{2}.K

The rate of heat transfer from the wire to the air per meter length is determined from the equation is given by:

Q=hA_{s}(T_{s}-T{\infin})\\\\=h\times(\pi\timesDL)\times(T_{s}-T{\infinity})\\\\=138.92\times(\pi\times3\times10^{-3}\times1)\times(280-20)\\\\=340.42W/m

The rate of heat transfer from the wire to the air per meter length is Q=340.42W/m

6 0
3 years ago
Compare the output of full-wave rectifier with and without filter
lara31 [8.8K]

Answer:

Full wave rectification flips the negative half cycle of the sine wave to positive so the result is two positive half cycles.

Explanation:

hope it helps a lil

4 0
2 years ago
What are the 5 major forest types?
Nataly [62]

Answer:

1. Equatorial Evergreen or Rainforest

2. Tropical forest

3. Mediterranean forest

4. Temperate broad-leaved forest

5. Warm temperate forest

Explanation:

4 0
4 years ago
Read 2 more answers
Write a python program to get the following output. 1-----99 2-----98 3-----97 . . . . . . 98-----2 99-----1
Zanzabum

Answer:

i dont know th answer can u help ?

Explanation:

8 0
3 years ago
Other questions:
  • A stem and leaf display
    12·1 answer
  • Question 44
    8·1 answer
  • Two synchronous motors having subtransient reactances of 0.8 and 0.25 p.u., respectively, on a base of 500 V 2 MVA are connected
    13·1 answer
  • A 2-kg ball B is traveling horizontally at 10 m/s when it strikes 2-kg ball A. Ball A is initially at rest and is attached to a
    9·1 answer
  • What are potential impacts of clean energy? Predict the impact on future<br> generations.
    14·1 answer
  • What are the four essential components of a UAS?
    12·1 answer
  • When using a Hammer I should always keep an eye on may fingers so as not to hit them.?
    14·2 answers
  • Hi all any one help me?? ​
    12·2 answers
  • What is the value of slip in the block rotor test? and why?​
    6·1 answer
  • This graph shows the US unemployment rate from<br> August 2010 to November 2011
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!