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.
#include<iostream>
#include<iomanip>
#include<cmath>
usingnamespace 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)
{
constfloat 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 '{'