Question: Write a Java program to track the growth of a plant. The initializations you need to work with can be found at http://userwww.sfsu.edu/-whsu/csc210/Projects/P4/P4.java Just edit
Write a Java program to track the growth of a plant. The initializations you need to work with can be found at http://userwww.sfsu.edu/-whsu/csc210/Projects/P4/P4.java Just edit this file to complete your program You are given two arrays that store the average temperature and rainfall in San Francisco, for months 0 to 11, representing January to December respectively final int NUMMONTHS 12 int [] avgTemp (46, 48, 49, 50, 51, 53, 54, 55, 56, 55, 51,47): int [I avgRain (5,3,3, 1, 1,0,0,0, 0, 1,3,4): You are starting a new plant in month 0. You are given the declaration for an array newGrowthl: newGrowthlil will keep track of the number of inches of growth in month i. int [] newGrowth; newGrowth new int NUMMONTHS]: What your program does: Prompt the user to enter the minimum and maximum temperature for the plant Prompt the user to enter the minimum rainfall for the plant (all temperatures and rainfall are integers, for simplicity) for each month i from 0 to 11, calculate newGrowthli]: if the average temperature for month i is the maximum, newGrowthlil is set to -1 (plant dies back); otherwise, newGrowthlil is set to the average rainfall for month i minus the minimum rainfall for the plant The plant starts at height-0 inches. For each month, calculate the height of the plant at the end of the month, and print a table as shown in the sample runs, displaying the month, the average temperature, the average rainfall, the new growth, and the height of the plant at the end of that month. (Align columns of the table using tabs, as in earlier projects.) Note that the height of the plant never becomes negative: the smallest height attained is always zero. A sample executable will be available on libra at -whsulcsc210/P4/PlantGrowth.class. Sample runs: Welcome to the 210 gardening planner! Enter minimum temperature for plant: 47 Enter maximum temperature for plant: 60 Enter minimum rainfall for plant: 0 Month Temp Rain Growth Plant Height 46 51 48 3 3 49 3 3 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
