ch 10 n 12 - ch. 10 Circuit:Circuit() { num_of_resistors =...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ch. 10 Circuit::Circuit() { num_of_resistors = 4; vs = VoltageSource(“vs”, 100, 0); r[0] = Resistor (“r1”, 2, 35); r[1]= Resistor(“r2”, 4, LARGE_RATING_WATTS); r[2] = Resistor(“r3”, 3, LARGE_RATING_WATTS); r[3] = Resistor(“r4”, 6, LARGE_RATING_WATTS); rL = LoadResistor(“rL”, 10, 20, 77.5, LARGE_RATING_WATTS); } void Circuit::solveCircuit() { Resistor req(“req”, 0 , LARGE_RATING_WATTS); for ( int i = 0; i<num_of_resistors; i +=2) { req = req + (r[i] || r[i+1]); } vs.amps() = req.amps() = rL.amps() = vs.volts()/ } for (int i = 0, i < num_of_resistors; i += 2) { r[i].across_volts() = r[i+1].across_volts() = ((r[i] || r[i+1}).ohms() / req.ohms()) * req.across_volts(); r[i].volts() = r[i+1].volts() = vs.volts() – r[i].across_volts(); r[i].amps() = r[i].across_volts() / r[i].ohms(); r[i].watts(); r[i+1].amps() = r[i+1].across_volts() / r[i+1].ohms(); r[i+1].watts(); } vs.watts(); rL.watts(); } ckt.vs.print(); ckt.rL.print(); output - 26013 65.2538
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Ch.12 solve a circuit with any number of resistors
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

ch 10 n 12 - ch. 10 Circuit:Circuit() { num_of_resistors =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online