For this project, you will need to write a complete Java program. You do not need to submit a design document, but your code design will factor into your grade. Note: You do not need to build a Swing GUI for this program.
1) Must allow the user to enter the simulation’s initial condition: the starting height of the billiard ball (yi).
2) Must simulate the billiard ball’s descent from height yi to the ground (y=0).
3) The output CSV file must have columns for the following data…
3.1) Time (in seconds) starting from 0
3.2) Height (in meters) of the ball
3.3) Velocity (in meters per second)
4) The output CSV file must contain the ball’s height and velocity at each second from the time the ball was dropped until the time the ball hits the ground.
User input is shown in bold, console output is shown in plain text.
Please enter simulation parameters…
Initial Height (in meters): 5
Writing to simulationdata.csv…
Note: Given the small amount of user interaction in this project, you may include more detail in your console output as the simulation runs. I would recommend doing so to help debug.
CSV File Format
The data generated by the program must be saved to a file where each row represents one height measurement. The first row of the file should list the column (variable) names, in this case time, height, and velocity. On each row after the column names, the three numerical values should be separated by a comma (,).
time, height, velocity
time, height, velocity
(Note: this example demonstrates the file format only, do not use it to verify the simulation data)
Valid CSV files can be opened in Microsoft Excel, Google Sheets, etc
Imagine you are collaborating with a physics lab on campus. They would like to compare data collected from real-world studies with simulated data. Several experiments were performed to study the effect of air resistance on a falling billiard ball. The team needs a program which can simulate the position of the billiard ball in free-fall under simple, idealized conditions and produce a CSV file of the ball’s position over time. Our simulation will neglect air resistance, etc.
Sphere falling from a height
The position or height of the falling billiard ball can be simulated with the following equation:
y(t) = yi – (1/2) * g * t^2
y(t) is the height of the ball at time t
yi is the starting (initial) height
g is the acceleration due to gravity (9.81 m/s^2)
t is the amount of time the ball has been falling