Advertisement
akosiraff

Download TreeGrowth

Apr 19th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1.  
  2. Download: http://solutionzip.com/downloads/treegrowth/
  3. PROJECT: TREE GROWTH
  4. MODULE 2
  5. PALMS for CS1 Java v1.0
  6. Introduction
  7. This project will provide students with experience in creating user-defined methods in Java, as well as an introduction to file input/output in Java. At the end of this project, students will…
  8. ? Be able to solve simple problems using Java ? Understand and be able to apply simple arithmetic expressions using Java variables ? Understand and apply the basic concepts behind Java methods ? Be able to solve simple problems using Java file I/O ? Understand the use of the file stream classes in Java
  9. Trees and Growth Patterns
  10. Trees provide a number of benefits for the environment. Trees are able to absorb dangerous gases such as carbon dioxide (CO2) while, at the same time, producing oxygen for us to breathe. Trees also absorb and distribute water that otherwise may lead to runoff, thus reducing pollution and loss of topsoil. Some forms of trees even produce food for us to eat (think: apple trees).
  11. As we plant trees strategically, we often want to know how tall a tree can be expected to grow. While there are environmental factors that impact tree growth patterns, we can approximate the height of tree if we know certain facts. As trees grow, they add approximately the same amount of mass each year. If we know this amount, we can compute the expected height of a tree over time. The height of a tree (h) can be approximated based on its age using the following formula:
  12. h = v???? 4
  13. where a = the amount of mass added to a tree each year and t is the age in years.
  14. Exercise #1: Create a Java class called TreeGrowth.java to compute the approximate height of a tree based on the amount of mass added each year (a double value) and the age in years (an int value). Make sure you create and use one method for each input, one for the computation, and one for the output. All numeric amounts should be precise to two decimal places. Here are few sample tests you can run to check if your program is working correctly:
  15. Test Case #1:
  16. Enter the Amount of Mass: 256.0 Enter the Age in Years: 81
  17. You entered a mass of 256.00 and an age of 81 years. The approximate height of the tree is 12.00 meters.
  18. Test Case #2:
  19. Enter the Amount of Mass: 5333.3333 Enter the Age in Years: 30
  20. You entered a mass of 5333.33 and an age of 30 years. The approximate height of the tree is 20.00 meters.
  21. Exercise #2: Copy TreeGrowth.java to TreeGrowth2.java. Modify the code to read the input data from a file called tree_data.txt and to output the computed result to a file called tree_results.txt. Your program should have no screen prompts or screen input and only have one piece of screen output – a message that says:
  22. Output file tree_results.txt is now complete.
  23. Hint: Check out the BufferedReader and PrintWriter classes.
  24. Deliverables
  25. Submit both of your .java files into the ANGEL dropbox before the specified due date. In addition, prepare a hard copy to present at the beginning of class on the specified due date. This hard copy should include a printout of the code (complete with line numbers) with a cover page (listing the assignment, your name, the course, and the date). All materials must be stapled.
  26. Download: http://solutionzip.com/downloads/treegrowth/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement