Time Intervals

HI I'm trying to write a program that reads the height of a tower and how long it would take an object to hit the ground. I think most of my code is correct but I'm getting a few errors.

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
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

void GenerateTable(float, float);

int main()
{
	float towerHeight;
	float deltaT;

	cout<<"Enter tower height in meters: ";
	cin>>towerHeight;
	cout<<"Enter the time intervals you would like: ";
	cin>>deltaT;
	cout<<endl;

	return 0;
}
void GenerateTable (float towerHeight, float deltaT)
{
	const float g =9.80655;
	float objectHeight;
	float t;

	cout<<setw(10)<<"Time"<<setw(9)<<"Height"<<endl;
	t=0.0;
	objectHeight = towerHeight;

	//display table
	cout.setf(ios::fixed);
	while (objectHeight>0)
	{
		cout<<setw(9)<<setprecision(2)<<t<<setw(10)<<objectHeight<<endl;
		t+=deltaT;
		objectHeight=towerHeight-0.5*g*pow(t,2);
	}//end while

	//object hits the ground.
	cout<<endl<<"SPLAT!!!"<<endl<<endl;


The errors I'm getting are:
warning C4305: 'initializing' : truncation from 'double' to 'const float'
warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
fatal error C1075: end of file found before the left brace '{'

Any help and explination would be great, Thanks.

you are missing } brace at the end of program and than you never called GenerateTable(float, float) function in the main function...
Ok I got it to let me input my height and time intervals but now it exits when i press enter. where should I put my pause function?
write
system("pause");
before
return 0;
Thanks, that worked but, now the program pauses before it can calculate and display the table
did you put GenerateTable(float, float) function in the main function??
like this??
GenerateTable(towerHeight,deltaT);
after
cout << endl;
Actually I put it in the wrong spot before. Thank you very much
gald to help... any time.. :)
mirec, do you have skype?
yes I do. why would you need it if i may ask?
Topic archived. No new replies allowed.