CSCI 605 Week 1 Assignment 1 solution




5/5 - (6 votes)

Your assignment is to create a calculator that can be used to do some simple physics calculations. It will need to be able to determine the distance an object travels in the downwards direction given some length of time based on gravity. It will also need to be able to calculate the velocity of the object after that length of time. Given the push to send people to Mars in the not so distant future, you will need to consider this problem for both the gravity on Earth and on Mars. For this you will need to find the gravity constant for both planets.


Some useful calculations are

Distance = ½ gravity * time2

Velocity = gravity * time


Your solution should accept two command line arguments. The first is the planet and the second is the time duration.


Example output:


>$ java GravityCalculator earth 5

The object’s position after 5.0 seconds is 122.63 m from starting position

Current velocity is 49.05 m/s


Note: the answer is rounded to the nearest hundredth decimal place.


Your solution should be named


Your solution should address potential issues if the command line arguments are incorrect. This will be tested!


You can only use basic types.

You may not use and existing classes that may solve part or all of this problem for you.


Correctness: You can lose up to 20% if your solution is not correct
Quality: You can lose up to 20% if your solution is poorly designed
Testing: You can lose up to 20% if your solution is not well tested
Explanation: You can lose up to 40% if you cannot explain your solution during the grading session