Homework Assignment One: A Simple Ballistic Calculator

The mathematician that helped you with the second lab assignment now has a new problem for you.

You now need to write a program that asks for

as in the picture below.

Given the initial speed (velocity), and the angle, you are to print a report in the user's name, about how far the projectile will go and how long it will take for it to land. The formulas the mathematician gives you are:

for the time it takes to fly, and

for the distance (how far the projectile lands), where g = 9.81 m/s2 is a constant.

These formulas assume the projectile does not hit anything, and that there is no friction with the air, and the only influence is that of the gravitational field of the Earth (which of course is an idealized situation, but that's OK for this problem).

The mathematician also gives some test cases to check your program, that should work like this.

frilled.cs.indiana.edu%java A1
Hello, and welcome to the ballistic calculator.
Please enter your name: Dave
Well, Dave what's the initial velocity?
Enter it here, with decimals (m/s): 100
Thanks. What is the angle you're shooting at?
Express it as an integer between 0 and 90: 30
Thanks. Here are the results: 
  Report for:          Dave
  Initial Velocity:    100.0 (m/s) 
  Angle:               30 (degrees) 
  Time Elapsed:        10.19367991845056 (seconds) 
  Distance at Landing: 882.798576742547 (meters) 
frilled.cs.indiana.edu%java A1
Hello, and welcome to the ballistic calculator.
Please enter your name: Dave
Well, Dave what's the initial velocity?
Enter it here, with decimals (m/s): 100
Thanks. What is the angle you're shooting at?
Express it as an integer between 0 and 90: 45
Thanks. Here are the results: 
  Report for:          Dave
  Initial Velocity:    100.0 (m/s) 
  Angle:               45 (degrees) 
  Time Elapsed:        14.416040391163046 (seconds) 
  Distance at Landing: 1019.367991845056 (meters) 
frilled.cs.indiana.edu%java A1
Hello, and welcome to the ballistic calculator.
Please enter your name: Dave
Well, Dave what's the initial velocity?
Enter it here, with decimals (m/s): 100
Thanks. What is the angle you're shooting at?
Express it as an integer between 0 and 90: 60
Thanks. Here are the results: 
  Report for:          Dave
  Initial Velocity:    100.0 (m/s) 
  Angle:               60 (degrees) 
  Time Elapsed:        17.655971534850938 (seconds) 
  Distance at Landing: 882.7985767425471 (meters) 
frilled.cs.indiana.edu%
Everything that the computer is printing is in color.

The solutions will be due next Wednesday at 11:59pm, and will be collected through QuizSite, which will be set up tomorrow for homework assignments collection. I'll have more info posted by tomorrow, but I wanted to post this file today, for you to start thinking about this problem already. Don't forget Lab 2 and the second In-Lab Assignment, meant to help you with that.

(This problem suggested by Tigger, who also helped with the formulas).


Last updated: Jun 24, 2001 by Adrian German for A201