Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program to track the growth of a plant. You are given two arrays that store the average temperature and rainfall in San

Write a Java program to track the growth of a plant. 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 [] 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 newGrowth[]; newGrowth[i] 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 newGrowth[i]: If the average temperature for month i is the maximum, newGrowth[i] is set to -1 (plant dies back); otherwise, newGrowth[i] 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 assignments.) Note that the height of the plant never becomes negative; the smallest height attained is always zero. Then add "month" comlumn. When the program is generating the table, it should be saving the table's data in a 2D array. This array holds items of different types, at least 2 types. image text in transcribed

run: Welcome to the 210 gardening planner! Enter minimun temperature for plant: 47 Enter maximm temperature for plant: 60 Enter minmum rainfall for plant: Index Month Temp RainGrovth Plant Height | Welcome to the 210 gardening planner! Enter minimum temperature for plant: 45 Enter maxinum temperature for plant: 50 Enter minimum zainfall for plant: 2 Index Month Temp Rain Growth Plant Height Jan 46 S Feb 483 Mar 49 3 dan Feb 48 3 Mar49 Apr 50 ay 51 un 53 Jul 54 Aug 55 Sep 56 Oct 55 Nov 51 Dec 47 3 Apr 0 1 - May 51 Jun 53 Jul 540 Aug S5 0 Sep 56 0 Oct 55 1 NOv Dec -1 +1 10 12 16 10 51 +4 FART 3, displaying the plantGrovthDatabase: PART 3, displaying the plantGrowthDatabase: Index Month Temp Rain Growth Plant Height Index Month Temp Rain Growth Plant Height Jan 46 Jan 46 Feb 48 3 Mar 49 3 Apr 50 1 May 51 1 un 530 Tul 54 Aug 55 Sep 56 0 Oct 55 NOw513 Feb 48 3 Maz 49 Apr 50 1 May Jun 53 Jul 54 0 Aug 55 Sep 56 0 +1 10 Nov 51 3 11 Dec 474 BUILD SUCCESSPUL (total time: 6 seconda) +3 +4 12 16 10 11 Dec 474 BUILD SUCCESSPUL (total tine: 4 seconds)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

2. How were various roles filled?

Answered: 1 week ago