Please help!
The ExperimentalFarm class represents crops grown on an experimental farm. An experimental farm is a rectangular tract of land that is divided into a grid of equal-sized plots. Each plot in the grid contains one type of crop. The crop yield of each plot is measured in bushels per acre.

A farm plot is represented by the Plot class. A partial definition of the Plot class is shown below.

public class Plot

{

private String cropType;

private int cropYield;



public Plot(String crop, int yield)

{

/* implementation not shown */

}



public String getCropType()

{

return cropType;

}



public int getCropYield()

{

return cropYield;

}

}

The grid of equal-sized plots is represented by a two-dimensional array of Plot objects named farmPlots, declared in the ExperimentalFarm class. A partial definition of the ExperimentalFarm class is shown below.

public class ExperimentalFarm

{

private Plot[][] farmPlots;



public ExperimentalFarm(Plot[][] p)

{

/* implementation not shown */

}



/** Returns the plot with the highest yield for a given crop type, as described in part (a). */

public Plot getHighestYield(String c)

{

/* to be implemented in part (a) */

}



/** Returns true if all plots in a given column in the two-dimensional array farmPlots

* contain the same type of crop, or false otherwise, as described in part (b).

*/

public boolean sameCrop(int col)

{

/* to be implemented in part (b) */

}

}

(a) Write the getHighestYield method, which returns the Plot object with the highest yield among the plots in farmPlots with the crop type specified by the parameter c. If more than one plot has the highest yield, any of these plots may be returned. If no plot exists containing the specified type of crop, the method returns null.

Assume that the ExperimentalFarm object f has been created such that its farmPlots array contains the following cropType and cropYield values.

The figure presents a two-dimensional array of Plot objects with 3 columns and 4 rows. The columns are labeled from 0 to 2, and the rows are labeled from 0 to 3. Each plot is labeled with a crop name and crop yield as follows. Row 0. Column 0, "Corn" 20. Column 1, "Corn" 30. Column 2, "Peas" 10. Row 1. Column 0, "Peas" 30. Column 1, "Corn" 40. Column 2, "Corn" 62. Row 2. Column 0, "Wheat" 10. Column 1, "Corn" 50. Column 2, "Rice" 30. Row 3. Column 0, "Corn" 55, Column 1, "Corn" 30. Column 2, "Peas" 30.
The following are some examples of the behavior of the getHighestYield method.

Method Call Return Value
f.getHighestYield("corn") ​farmPlots[1][3]
f.getHighestYield("peas") farmPlots[1][0] or farmPlots[3][2]​
f.getHighestYield("bananas") null
Write the getHighestYield method below.

/** Returns the plot with the highest yield for a given crop type, as described in part (a). */

public Plot getHighestYield(String c)

Answers

Answer 1

Answer:

See explanation. I divided it up into part a and b.

Explanation:

PLOT CLASS CODE:

public class Plot

{

private String cropType;

private int cropYield;

public Plot(String crop, int yield)

{

  this.cropType = crop;

  this.cropYield = yield;

}

public String getCropType()

{

return cropType;

}

public int getCropYield()

{

return cropYield;

}

public String toString() {

  return this.cropType+", "+this.getCropYield();

}

}

EXPERIMENTAL FARM CLASS CODE:

public class ExperimentalFarm

{

private Plot[][] farmPlots;

public ExperimentalFarm(Plot[][] p)

{

  this.farmPlots = p;

}

/** Returns the plot with the highest yield for a given crop type, as described in part (a). */

public Plot getHighestYield(String c)

{

  Plot plot = null;

  int highest = this.farmPlots[0][0].getCropYield();

  for(int i=0;i<4;i++)

  {

     for(int j=0;j<3;j++)

     {

        if(farmPlots[i][j].getCropType().equalsIgnoreCase(c) && farmPlots[i][j].getCropYield()>highest)

        {

           highest = farmPlots[i][j].getCropYield();

           plot = farmPlots[i][j];

        }

     }

  }

  if(plot != null)

  return plot;

  else

  return null;

/* to be implemented in part (a) */

}

/** Returns true if all plots in a given column in the two-dimensional array farmPlots

* contain the same type of crop, or false otherwise, as described in part (b).

*/

public boolean sameCrop(int col)

{  

  boolean check = true;;

  String crop = farmPlots[0][col].getCropType();

  for(int i=0;i<4;i++)

  {

     if(!farmPlots[i][col].getCropType().equalsIgnoreCase(crop))

        {

        check = false;

        break;

        }

  }

  return check;

/* to be implemented in part (b) */

}

}

MAIN CLASS CODE:

public class Main {

  public static void main(String[] args)

  {

     Plot p1 = new Plot("corn",20);

     Plot p2 = new Plot("corn",30);

     Plot p3 = new Plot("peas",10);

     Plot p4 = new Plot("peas",30);

     Plot p5 = new Plot("corn",40);

     Plot p6 = new Plot("corn",62);

     Plot p7 = new Plot("wheat",10);

     Plot p8 = new Plot("corn",50);

     Plot p9 = new Plot("rice",30);

     Plot p10 = new Plot("corn",55);

     Plot p11 = new Plot("corn",30);

     Plot p12 = new Plot("peas",30);

     Plot[][] plots = {{p1,p2,p3},

                 {p4,p5,p6},

                 {p7,p8,p9},

                 {p10,p11,p12}};

     ExperimentalFarm f = new ExperimentalFarm(plots);

     Plot highestYield = f.getHighestYield("corn");

     Plot highestYield1 = f.getHighestYield("peas");

     Plot highestYield2 = f.getHighestYield("bananas");

     try {

     System.out.println(highestYield.toString());

     System.out.println(highestYield1.toString());

     System.out.println(highestYield2.toString());

     }

     catch(Exception e)

     {

        System.out.println("null");

     }

     System.out.println("The method call f.sameCrop(0)");

     System.out.println(f.sameCrop(0));

     System.out.println("The method call f.sameCrop(1)");

     System.out.println(f.sameCrop(1));

  }

}


Related Questions

Anna has taken up her first job as an IT help desk technician. Which certification will help her advance her career?

A. Microsoft Certified Solutions Expert
B. CompTIA A+
C. Cisco Certified Network Professional
D. Oracle Certified Professional

Answers

B, I think.

Cisco = networking
Oracle =
Networking as well I think

Define an array and why it is needed in programming

Answers

Answer:

An array is a data structure, which can store a fixed-size collection of elements of the same data type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

Explanation:

Happy to help :-)

Answer:

An array is a data structure, which can store a fixed-size collection of elements of the same data type. a array is used to store a collection of data, but it´s often more useful to think of an array as a collection of variables of the same type.

Explanation:

I need help now I really do what is the answer thank you

Answers

the answer is c
just replace the y with the y value and the x with the x value

Write a function named buildArray that builds an array by appending a given number of random two-digit integers (10-99). It should accept two parameters — the first parameter is the array, and the second is an integer for how many random values to add, which should be input by the user.

Answers

Answer:

The function in C++ is as follows:

void buildArray(int arr[], int n){

   srand(time(NULL));

   for(int i = 0;i<n;i++){

       arr[i] = rand() % 99 + 10;    }

   for(int i = 0;i<n;i++){

       cout<<arr[i]<<" ";

   }

}

Explanation:

This defines the function

void buildArray(int arr[], int n){

This klets the program generate different random numbers

   srand(time(NULL));

This iterates from 0 to n - 1 (n represents the length of the array)

   for(int i = 0;i<n;i++){

This generates random 2 digit integer into the array

       arr[i] = rand() % 99 + 10;    }

This iterates through the array and print the array elements

   for(int i = 0;i<n;i++){

       cout<<arr[i]<<" ";

   }

}

See attachment for complete program that includes the main

What type of malicious software tries to gather information about you without your consent?
Select one:
a. Spyware
b. Viruse
c. Malware
d. Ransomware

Answers

Answer:

B-malware

Explanation:

I do tech and i help work on computars.

5.
1 point
*
*
dog#
Choose
This is a required question

Answers

Answer:

WHAT IS YOUR QUESTION ⁉️⁉️

SO I CAN HELP YOU

BECAUSE I APPLIED IN BRAINLER HELPER

Convert the given for loop to while loop and find the output of the program assuming the
value entered for num is 15.
num = int (input ("Enter a value"))
sum =0
count=0
for i in range (1, num):
if i%2 == 0:
count += 1
sum += i
print(sum)
print(count)

Answers

Answer:

Explanation:

num = int (input ("Enter a value"))

sum =0

count=0

i = 1

while i < num:

 if i%2 == 0:

        count += 1

        sum += i

        i += 1

 i += 1

print(sum)

print(count)

The output assuming num is 15 would be

56

7

Fill in the blanks to complete a summary of this part of the passage. For the power of Patents

Answers

i’m confused . what do i do?

Answer:

??

Explanation:

2. The
is the main and usually largest data storage hardware device in a computer​

Answers

The answer you are looking for is either Hard Drive or SSD (Solid State Disk).

3.4 lesson practice quiz edhesive

Answers

3.4 lesson practice quiz edhesive :

Write a program to check if user inputs "yellow"

Answer:

In Python:

col = input("Enter Color: ")

if col == "yellow":

   print("True")

else:

   print("False")

Explanation:

This prompts the user for color

col = input("Enter Color: ")

This checks if color is yellow

if col == "yellow":

If true, this prints true

   print("True")

If otherwise, this prints false

else:

   print("False")

How many days are depicted in the movie stand by me?

I need the answer

Answers

Answer:

I have no idea

Explanation:

Multiple choice:
Select the terms relating to comparisons for equality.


A) ==

B) ^=

C) <>

D) =

E) <

F) !=

G) <=

H) >=

Answers

Answer:

Well there is only 1

"==" is checking for equality and "=" is assigning a value to a variable. Although "==" should be the only answer, since the question is asking you to select multiple, I'd select both of those

Jim needs to ensure that a list of items includes the information regarding suppliers in the same report. Which control should he add in Design view? subreport text box combo box label

Answers

Answer:

Labels

Explanation:

The label can be used to attach information. This feature can be used by applying it to the Design View Form. The property sheet feature contains a list of adjustments such as color, font size, and name that the user can apply to the text.

Labels meant for headings can also be used to display commands on the form. Most label controls have a fixed text by default. When a user wishes to attach information to a list, the label control can be used to achieve that.

What is modularity?
A.
the process of reusing existing modules from other programs
B.
the process of grouping together smaller segments into larger modules
C.
the process of consolidating different parts into a whole program
D.
the process of breaking down a program into small

Answers

Answer:

Option D

Explanation:

Modularity in general defines the flexibility of a system. It is the degree to which a system can be broken down into smaller segments and then rearranged or recombines into new groups. Modularity is determined for multiple disciplines each having their own drawbacks.

How would someone know if their were communication devices placed in their homes illegally. Cameras and USB controlling devices?

Answers

Explanation:

Among the recommended options often suggested by IT experts includes:

In the case of cameras, using a cell phone around the home switch results in unusual signal interference possibly indicates a special radio frequency coming from the illegally implanted device.The use of a mobile app designed for detecting hidden cameras. For example, the ”detect hidden cameras” app available on iPhone or Android mobile devices is a good tool. This app automatically senses  the radio frequencies of any hardware within the device range.

1. Many photographs tell a story. What is the story of this photograph? What is happening? Where is the photograph taken? Why is the photograph taken?

2. Good photographs create an emotion or feeling. What emotion does this photograph make you feel? How does the photographer create this emotion in the photograph?

Answers

Answer:

Answer below! Hope I am correct!( I know what happened in that picture, I am sure!)

Explanation:

What is the story of this photograph?

The story is... I think there is a earthquake going on in San Francisco...

What is happening?

There is a earthquake and people are trying to run away & trying to stay safe...

Where is the photograph taken?

Looks like a long time ago, maybe it’s in California (San Francisco) April 19 or 18, 1906.

Why is the photograph taken?

It was a really important & significant earthquakes! So it will be part of history & will be remembered....

What emotion does this photograph make you feel?

It makes me feel really horrible to see that there is a earthquake, I think many people died :( ......

How does the photographer create this emotion in the photograph?

By all the smokes... I can also see people trying to run away from the earthquake.. also I can tell they are really scared!

Hope this helps!

By:BrainlyAnime

ONCE AGAIN Can somebody explain the difficulties and hardships of being a computer engineering?

Answers

Answer:

The only thing I can think of, is stress. I cannot tell you how frustrating it is when you're writing code and it decides to bug out because of some little mistake. For hours you're writing and find out that you're missing a single ";" or an indent.

When you're writing out code in order to solve a problem, you need to break it down step by step in order to actually write it. Otherwise, you'll miss a bunch of steps

Select the correct images Jane has to pick images that portray action photography. Which of these images would she pick? please help me​

Answers

Answer: i think its the horse the basketball and the bike hopefully i helped

Explanation:

3. Describe the types of input the peripheral nervous system receives in each of the three scenarios.

Answers

Answer:

espanel hjcrkl cuecls oob

While many instruments have been "electrified", there is no such thing for the drums.
Group of answer choices

True

False

Answers

False, because they are called percussion group
False. Because it is fake not true

What is the advantage of using the Selection pane to modify SmartArt?
O It can insert or edit individual graphic boxes on a slide.
O It helps to reorder or remove on-screen elements that overlap.
O It adds a new overlay for creating overlapping graphics and text.
Olt automatically aligns graphic elements to on-screen guidelines.

Answers

Answer:

B

Explanation:

Bc I said so

Answer:

It helps to reorder or remove on-screen elements that overlap

Explanation:

edge 2022

Michelle works in retail and can't decide what product to include in the store's front window display. what is the first step she should take to solve this problem?

Answers

Answer:

she should look at the most wanted product she has in her store and put that out on display

Explanation:

Demographics and psychographics influence database marketing.


False

True

Answers

Answer:

true is the correct answer

I’m timed

Which is true of software bugs?

Bugs can only be identified when error messages appear.
The number of bugs are reduced by careful attention to programming conventions.
Bugs cannot cause long-term harm.
Most software initially contains no bugs.

Answers

Answer:

It is most likely:

B. The number of bugs are reduced by careful attention to programming conventions.

Explanation:

Hope these points help you.
I love.

Answers

Answer:

Explanation:

thanks, have a great day

Answer:

Thank you so much for the free points! You are so kind.

Explanation:

I hope you have a wonderful rest of your day and if these points were not for me then I must have misunderstood. Have a good one!

(ɔ◔‿◔)ɔ ♥

What is a server? Why is it so important?

Answers

Answer:

Servers not only help your business with data storage, but they will also improve efficiency and productivity. As employees can access data and information from any workstation it means they can work from home, while travelling or from a different office.

Answer:

hope this help

Explanation:

A server is a computer or system that provides data,resources,service or programs. This is important because this stores our information and helps us surf online.

After saving a chart, where can you find it again to use it for a different data set?

sparklines
saved charts
templates
formats

Answers

Answer:

C. Templates

Explanation: Edge 20201

Answer:

templates

Explanation:

How do you play game on phone

Answers

You download a game from the App Store
Download it and play it

15.A telecommunication company wants to start a business in Dera Ghazi khan. For Information technology (IT) support, they hired an IT Staff and want to buy hardware from the market. Choose the hardware name which is important for the company.

Answers

Answer:

The company should have computer with secured bandwidth and LAN system which can connect employees on one network.

Explanation:

Telecommunication company will require a network setup which can connect employees on a single network. The network security should be efficient which keeps the LAN network secure from cyber attacks. The IT staff should buy Telecoms equipment and hardware and keep them in a secured control room whose access is limited to certain users only.

The strength of gravity on the Moon is 1.6
Newtons per kilogram. If an astronaut's mass is 80
kg on Earth, what would it be on the Moon?​

Answers

Answer:

[tex]Mass = 80kg[/tex]

Explanation:

Given

On Earth

[tex]Mass = 80kg[/tex]

On the moon

[tex]g = 1.6N/kg[/tex]

Required

The astronaut's mass on the moon

The mass of an object do not change base on location

So, if the mass of the astronaut is 80kg on earth, it will be 80 kg on the moon.

Hence:

[tex]Mass = 80kg[/tex]

Other Questions
I really need this answer:What resources would cause the most trouble for the South and be the greatest advantage to the North? This is talking about the Civil War. please helppp Determine if the side lengths 6, 11, and 19 form a triangle. If it is a triangle, classify it by its sides.scalene triangleequilateral triangleisosceles triangleIt's not a triangle. Find the slope given the following points:(-1, 2) (3,5) find the product 12(-3) Q: Instead of teddy bears on Valentine's Day, let's give everyone bear hugs.What is the indirect object and what is the direct object? HELP PLEAES ALSO PLEASE DO NOT CLICK THE LINKS THIS GUY IS PUTTING Which of these characteristics will produce the most dense water?(Giving Brainlist For Correct Answer!)-High salinity, high temperature-High salinity, low temperature-Low salinity, high temperature-Low salinity, low temperature Who was the general of WW2 What effect does the word tamely have on the meaning of the excerpt from "The Quarrel"?It reveals Agamemnon is mighty and cannot be controlled.It suggests that Agamemnon thinks Achilles is insulting him.It reveals that Agamemnon is trying to belittle Achilles.It suggests that Agamemnon is afraid Achilles will overpower him. Demographics and psychographics influence database marketing.FalseTrue on a map to cities measure 6.2 cm apart if the scale of the map is 5 cm/ 10 miles and how many miles apart are the cities PLEASE HELP ME THIS ANSWER DRIVING ME CRAZY!!! A basketball game court is 94 feet long and 50 feet wide. Ryan used long steps to estimate the length of the court as 93 feet and width 48 feet. What is the percent error of ryan's measured area round your answer to the nearest hundred. (URGENT) will mark brainliest if you help me answer thisQuestion 1 options:OH-H+Question 2 options:OH-H+Question 3 options:soapbleachapple juiceammoniaQuestion 4 options:lemon juicebleachmilkstomach acidQuestion 5 options:0-38-100-68-14Question 6 options:0-38-100-68-14Question 7 options:sourbittersweetsaltyQuestion 8 options:slipperybrittlemalleablecorrosiveQuestion 9 options:slipperybrittlemalleablecorrosiveQuestion 10 options:sourbittersweetsalty helpp what is the y- value when x equals 21? y = 650 - 16 (x) help please......... I need the answer fast ASAP Anorexia is explained by Watzke as the big brain overriding a signal of hunger. Do you agree with this explanation? What, if any, other factors might contribute to anorexia? Do you believe that anorexia is simply a scientific disease? The producer es in my food web are can you pls help me with this it's about the immune system