Download Category: - (69.58 KB)

PALMS for CS1 Java v1.0
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…
? 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
Trees and Growth Patterns
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).
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:
h = v???? 4
where a = the amount of mass added to a tree each year and t is the age in years.
Exercise #1: Create a Java class called 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:
Test Case #1:
Enter the Amount of Mass: 256.0 Enter the Age in Years: 81
You entered a mass of 256.00 and an age of 81 years. The approximate height of the tree is 12.00 meters.
Test Case #2:
Enter the Amount of Mass: 5333.3333 Enter the Age in Years: 30
You entered a mass of 5333.33 and an age of 30 years. The approximate height of the tree is 20.00 meters.
Exercise #2: Copy to 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:
Output file tree_results.txt is now complete.
Hint: Check out the BufferedReader and PrintWriter classes.
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.

Write a Review

Get a fresh solution of this question. Ask it now to our experts.

Ask Your Question

We have verified professionals who are ready to answer your question.


Save Time and Money

We choose experts who can quickly answer your question and that suit your budget.


Get Your Answer

Your satisfaction is 100% guaranteed. You can keep on asking questions until you get the answer you need.