I need help ASAP! D: Array/Loop Project

I have this project that has been giving me trouble for hours on end!

The link is here:


https://elearning.utdallas.edu/webapps/blackboard/execute/content/file?cmd=view&content_id=_635388_1&course_id=_37168_1&launch_in_new=true


I haven't had any success with any of the methods I've tried. Any suggestions will be greatly appreciated!


This is what I have to read the file (ignore the cout statement and storing it to the file, I was just making sure it read correctly.):


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int calculations(string, string);

int main()
{
	float coordinates;
	ifstream PilotFlight; 
	ofstream outputFile; 
	string pilot_name;
	double coordinateX[15];
	double coordinateY[15];
	
	PilotFlight.open("pilot_routes.txt"); 
	outputFile.open("pilot_areas.txt"); 
	
	if (PilotFlight.is_open())
	{ 
		string line;
		while (PilotFlight.good())
		{
			getline(PilotFlight, line);
			
			cout << line << endl;
			outputFile << line << endl;
		}
		
		
	}
	
	return 0;
}


Also please ignore the due date, as it is wrong.
Last edited on
We need username and password to access that page... Why don't you just write what you have to do?


Problem: Darth Vader wants to check that his TIE fighter pilots are patrolling adequately-sized regions of
the galaxy. He has files of data that contain the patrol coordinates for each of his pilots. With the fear
of being force choked, you have agreed to write a program that analyzes the data and determines the
size of the area patrolled by the pilots.
Given a list of checkpoint coordinates logged by the pilot that represent a polygonal shape, the area of
the shape can be calculated with the following formula
𝑛−2
1/2|∑(𝑥𝑖+1 + 𝑥𝑖)(𝑦𝑖+1 − 𝑦𝑖)
𝑖=0
http://gyazo.com/1394091de164ccf1bd9419951ea2519d (for the formula)

|
Input: All input will come from a file named pilot_routes.txt. The file will contain the pilot’s first name
followed by a list of coordinates separated by spaces. Each line in the file will represent a different pilot.
The format for each line will be the pilot’s first name followed by a list of x and y coordinates. There will
be a space between each pair of coordinates and a comma between the x and y coordinates. The first
and last set of coordinates will always be the same. See the sample below.

Output: All output will be written to a file named pilot_areas.txt. Once the calculation is performed, the
pilot’s name will be written to the file followed by a tab and the area of the polygonal shape
represented by the coordinates. The area should be rounded to 2 decimal places. Each pilot’s data will
be written on a separate line.

Limitations
 There is no limit to the number of pilots listed in the file.
 No pilot will have more than 15 coordinates associated with his/her patrol.
 Arrays must be used to hold the pilot’s coordinates
 Modular programming is required

Samples:
Input Line: Han 4,0 4,7.5 7,7.5 7,3 9,0 7,0 4,0
Output Line: Han 25.50
Topic archived. No new replies allowed.