$39
Objectives
Introduction: Mission to Mars
Your friend has been playing a new Mars Colony simulator nonstop! They are always talking about how cool it would be if they could be a on the first real-life mission to Mars! To amuse your friend, you have decided to create a series of programs about the possible first colony on Mars.
Problem: How Much Fuel Will We Need? (marsfuel.c)
The biggest problem our mission will face is getting our supplies off Earth and on their way to Mars. Earth and Mars have different orbits, which means the distance between the two planets is always changing. Based on the current distance between these two celestial bodies our astronauts may spend varying amounts of time in transit.
You will need to ask the user for the distance between Earth and Mars on the day of the expected launch. You can then determine the number of days we expect the shuttle to be traveling using the following formula:
Distance / 261,904
If each day requires 11,000 pounds of rocket fuel, determine how much fuel will be necessary for the trip.
This may not be the most precise calculation, so our team will also add in a 20% “contingency” – an extra amount of fuel in case we run out. Add an additional 20% to the amount needed for the trip and print this final amount to the user.
Input Specification
1. The distance will be a positive integer.
Output Specification
Output the number of pounds of fuel needed as a real number rounded to two decimal places using the format below:
You will need X.XX pounds of fuel to get to Mars!
Output Sample
Below are some sample outputs of running the program. Note that these samples are NOT a comprehensive test. You should test your program with different data than is shown here based
2
on the specifications given above. In the sample run below, for clarity and ease of reading, the user input is given in italics while the program output is in bold. (Note: When you actually run your program no bold or italics should appear at all. These are simply used in this description for clarity’s sake.)
Sample Run #1
How far away will Mars be on the day of the launch?
55000000
You will need 2772008.05 pounds of fuel to get to Mars!
Sample Run #2
How far away will Mars be on the day of the launch?
250000000
You will need 12600036.65 pounds of fuel to get to Mars!
Acceptable Resources
Remember, the use of online help sites is strictly prohibited. The only acceptable resources for these assignments are below:
Style Notes
Please review the course Style Guide on the webcourse, with special attention to the following notes:
3
Deliverables
One source file – marsfuel.c – is to be submitted over WebCourses.
Restrictions
Although you may use other compilers, your program must compile and run using a standard C Development Environment. Your program should include a header comment with the following information: your name, assignment number or title, and date. Also, make sure you include comments throughout your code describing the major steps in solving the problem.
Grading Details
Your programs will be graded upon the following criteria: