Homework Help: Using C++ to find the electric field vectors

1. Sep 19, 2007

gallag32

im not too sure if this belongs here or not but i figure ill give it a shot.

Im not too bad at solving things myself, i could do this problem without C++(though it would take some time). Unfortunately, i need to use C++.

Rather than try to explain what i need help with ill copy and paste the problem and then add the area i am having trouble with:

Write a computer program that finds the scalar components of the electric field for a system of point charges. The program must read an input file of data. The input file is to consist of a line of data for each of the N charges. The first line of the file is to be the number N. The second line should be the coordinates of the point at which the field is to be found. Each of the next lines is to give the charge q(i) in coulombs, the values of xā(i),yā(i), and zā(i) for the source charges. Run your program for the following input::

9
0.25, 0.75, 0.60, (This is the field point)
0.20, 0.50, 0.00, 0.00 (This and the following are the source charges and their coordinates.)
0.10,0.354,0.354, 0.00
0.20,0.00,0.50,0.0
0.10,-0.354,0.354,0.00
0.20,-0.50, 0.00, 0.00
0.10,-0.354,-0.354,0.00
0.20,0.00,-0.50,0.0
0.10,0.354,-0.354,0.00
0.20,0.00,0.00,-1.00

submit your source code, the values Ex, Ey, Ez, and E expressed in terms of a unit vector R1.

The issue i am having is that i do not have a good backround in C++, i know how to open a file, and find out which number in the file is largest. Opening a system of data and then performing a line by line analysis is another story. This is one situation in which lucking out and getting the "easy" comp sci professor is will not leave you in a good situation.