#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
usingnamespace std;
//***************************
// Function beforeSplat *
// This function calculates *
// the time taken to fall. *
//***************************
int beforeSplat(int distance)
{
return (sqrt((2*distance)/9.8));
}
//*****************************
// Function printHeader *
// This function displays *
// the table for information. *
//*****************************
void printHeader(ofstream& Splat)
{
Splat<<" Distance \t Time\n"
<<" (meters)\t (seconds)\n"
<<"~~~~~~~~~~~~~~~~~~~~~~~"
<<endl;
}
//*****************************
// Function print *
// This function displays *
// the output of information. *
//*****************************
void print(int distance, int time, ofstream& Splat)
{
Splat<<"| "<<left<<setw(13)<<distance
<<" "<<time<<" |"
<<endl;
}
//*****************************
// Function main *
//*****************************
int main()
{
ofstream Splat;
Splat.open("Everest.out");
int time;
printHeader(Splat);
for(int distance = 500; distance <= 12000; distance+=500)
{
time=beforeSplat(distance);
print(distance, time, Splat);
}
Splat<<"~~~~~~~~~~~~~~~~~~~~~~~"
<<"\n\n\n\t Everest.out has been saved to file.";
Splat.close();
return 0;
}
No sorry your advice didn't help it didn't change any sort of formatting.
If you run my code you will see two columns the one on the right (time) needs to be reverse order. It's backwards! and needs to be ascending rather than desending