NEED final Project help!

I'm working on a final project for my computer programming in C++ class, I know nothing about programming, and I think I bit off more than I could chew with this project.

My proposed project idea was to set up a scenario where if you were on a beach and set your stuff down at a certain distance from the shore, you could use this program to find out how long it would take the tidal water to reach your stuff and get it wet.

I was thinking about doing something like calling the time and water level(which I translated from height to distance up the shore) data in a loop that would essentially let me set a time and increment the time until the translated water height hits a certain value.

My teacher helped me write a bit of code but I am very stuck still. Any help?

The data looks like this

2014-04-22 00 00 1.690
2014-04-22 00 06 1.663
2014-04-22 00 12 1.624
2014-04-22 00 18 1.578
2014-04-22 00 24 1.529
2014-04-22 00 30 1.483
2014-04-22 00 36 1.391
2014-04-22 00 42 1.365
2014-04-22 00 48 1.299
2014-04-22 00 54 1.214.....


And here is the code so far..



using namespace std;

int main(int argc, char** argv) {
{
double *water = new double[2000];
double *timer = new double[2000];
double *distance = new double [2000]; //
ifstream f;
string d; //date
int h; //hour
int m; //minute
string w; //water
int i;
int z = 0;
f.open("p2.txt");
while(!f.eof()) {
f >> d; //date
f >> h; //hour
f >> m; //minute
f >> w; //water level
timer[z] = (double) z;
water[z] = atof(w.c_str());
distance[z] = water[z] / sin(0.0872664626);
z++;
cout << z << " Time: " << h << ":" << m << " " << atof(w.c_str()) << endl;
}
cout << "end of reading" << endl;
int n = z;
for (i = 0; i < n; i++) {
cout << timer[i] << " " << h << ":" << m << " " << distance[i] << " " << endl;
}
cout << endl;
}
return 0;
}
Use code tags!!! http://www.cplusplus.com/articles/jEywvCM9/
What are you stucked on?

Aceix.
Sorry, super new here.
Last edited on
I think I'm almost there!

I'm just having trouble getting it to print out the corresponding time with each distance. Right now I have it set to print the value for m (minutes) but it is staying at a constant 54. How would I get it to print out the corresponding hour and minute values with each distance?

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
36
37
38
39
40
41
42
int main(int argc, char** argv) {
    {
        double *water = new double[2000];
        double *timer = new double[2000];
        double *distance = new double [2000]; //
        ifstream f;
        string d; //date
        int h; //hour 
        int m; //minute
        int y;
        string w; //water
        int i;
        int z = 0;
        f.open("p2.txt");
        while (!f.eof()) {
            f >> d; //date
            f >> h; //hour
            f >> m; //minute
            f >> w; //water level
            timer[z] = (double) z;
            water[z] = atof(w.c_str());
            distance[z] = water[z] / sin(0.0872664626);
            z++;
            //         cout << z <<  " Time: " << h << ":" << m << " " << atof(w.c_str()) << endl;
        }
        cout << "end of reading" << endl;
        int n = z;
        for (i = 0; i < n; i++) {
            if (distance[i] > 20.00){

                cout << "Your feet will be wet until " << m << endl;
            cout << " The tide is standing at " << distance[i] << " feet from the shore." << endl;
            }
            else{
                cout << "Your feet are just fine." << endl;
            }
        }

        cout << endl;
    }
    return 0;
}
Last edited on
Topic archived. No new replies allowed.