Ok so hers the deal im in a programming class and i am attempting to solve this problem but i have no idea how to go at it really. Its due tomorrow and i had no Idea where else to go. Thanks in advance.

Write analysis program to read the circuit
components from a file. The format of the input file is:

"number of resistors in circuit"
"voltage source name" "source volts" "source rating"
"resistor name" "resistor ohms" "resistor rating"
......
"load resistor name" "load lower ohms" "load upper ohms" "load average watts"

An example file named input6.dat is attached.

Solve the following problem for the circuit data in the
input6.dat file.

If the power dissipated in resistor r1 goes above 35
watts, the resistor will burn and its resistance will jump
to 1000000 ohms.

Solve the circuit 100,000 times (using random values for the
load).

During the 100,000 simulations, count the number of times that
the 2 ohm resistor burns up. Also, calculate the average
voltage delivered to the load resistor when the 2 ohm
resistor has burned up.

Your program should output only two numbers on separate lines
as follows:

1-Number of times that the 2 ohm resistor burns

2-Average voltage delivered to the load resistor calculated
over the cases where the 2 ohm resistor has burned up

The seed to use for the random number generator is 100000

*The way the resistors are paired are as follows, r1 and r2, r3 and r4, r5 and r6 are in parallel with each other, and in series as a group. so r1=r2 is in series with r3=r4... etc.

This is What is in the Dat file that they gave us:
6
vs 100.0 1000.0
r1 2.0 20.0
r2 4.0 100000.0
r3 3.0 100000.0
r4 6.0 100000.0
r5 4.0 100000.0
r6 8.0 100000.0
rL 10.0 20.0 77.5

Here's a start:

#include <fstream>
#include <iostream>
#include <cstdlib>
#include <ctime>

int main()
{

  // your code goes here

  return 0;
}

Then make sure you understand http://en.wikipedia.org/wiki/Ohm%27s_law and you should be good to go.

commented: The OP needs one of these :) http://en.wikipedia.org/wiki/Tardis since they decided to "bless" the forum with their presence with only 24 hours to go. +29

Get a pencil and some paper. Break down the problem step by step. Pay attention to detail. Once you've solved on paper start writing your code. No one here will give you code, what you'll get here is good advice.

Get a pencil and some paper. Break down the problem step by step. Pay attention to detail. Once you've solved on paper start writing your code. No one here will give you code, what you'll get here is good advice.

thats really all i need, iv written out the code to solve the problem mathmatically however the part im stuck on now is that I cant seem to figure out how to import the data from the file

thats really all i need, iv written out the code to solve the problem mathmatically however the part im stuck on now is that I cant seem to figure out how to import the data from the file

It will depend on how the file is organized. You'll need to use an ifstream from the fstream library.

http://www.cplusplus.com/doc/tutorial/files/

In your case, the file looks like this:

6
vs 100.0 1000.0
r1 2.0 20.0
r2 4.0 100000.0
r3 3.0 100000.0
r4 6.0 100000.0
r5 4.0 100000.0
r6 8.0 100000.0
rL 10.0 20.0 77.5

So figure out what needs to be stored and what variables you need and read them in.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.