Instructions PoDjava GrainCalculator.java New Today we are working with basic methods Farmer loe wants you to help him determine how much grain he can expect to harvest this year, based on a formula that he has put together You will need to create a method called 'calculateGrain within the "Grain Calculator java class. This new method will make his calculations for him Details Input public class GrainCalculator { public GrainCalculator() { // Create the calculatecrain sethod here! // Hint: dividing by 1000 might give 11 4 different result than dividing by 1000.0 The input for this program is handled for you. Processing You will need to create a new method within the "GrainCalculator java class This method will be called 'calculateGrain, make sure you get the name right! Here are some details on the GrainCalculator dass 12 GrainCalculator int: calculateGrain (int, int, As you can see, this class is very simplistic: We will take care of the instantiation of this class, the input, and calling the method for you. All you need to do is write the calculateGrain method in the space provided. The calculateGrain method takes in 3 integers as input int width of grain field int-length of grain field int rainfall this year (in millimeters) It then makes a simple calculation to determine how much grain fin pounds) will be harvested, and returns the result as an integer The calculation is as follows expectedGrain-width length rainfall/1000) The value of expectedGrain is then returned Remember, we want to return an Int so you might need to convert your result to an integer before returning it! Output The output is already handled for you, tor Sample Input/output you, too. An example is shown below. Input: (handled for you!) 200 300 1100 Processing for this example: expectedGrain-200 300 1100/10001-660000 convert 66000 0 to 66000 and retum that value Output (also handled for you!): Farmer Joe has a grain field with a width of 200 meters and a length of 300 meters There was about 1100mm of rainfall this year Farmer Joe can expect about 66000 kilograms of grain this year. GrainCalculator.java PoDjavaⒸ import java.util.Scanner; New public class POD ( pulitic static void main(String[] args) { Scanner input her Scanner (System.in); in width input.nextInt(); int length input.nextInt(); Int rainfall input.nextInt();) GrainCalculator grainCalculator How GrainCalculator(); In expectedGrain grainCalculator.calculateGrain(width, length, rainfall); System.out.println("Farmer Joe has a grain field with a width of "width" meters and a length of "length" meters."); System.out.println("There was about "rainfall-"mm of rainfall this year."); System.out.println("Farmer Joe can expect about " expectedGrain" kilograms of grain this year.");  Please give proper explanation and typed answer only.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

Instructions

PoDjava

GrainCalculator.java

New

Today we are working with basic methods Farmer loe wants you to help him determine how much grain he can expect to harvest this year, based on a formula that he has put together You will need to create a method called 'calculateGrain within the "Grain Calculator java class. This new method will make his calculations

for him

Details

Input

public class GrainCalculator {

public GrainCalculator() {

// Create the calculatecrain sethod here!

// Hint: dividing by 1000 might give

11 4 different result than dividing by 1000.0

The input for this program is handled for you.

Processing

You will need to create a new method within the "GrainCalculator java class This method will be called 'calculateGrain, make sure you get the name right! Here are some details on the GrainCalculator dass

12

GrainCalculator

int: calculateGrain (int, int,

As you can see, this class is very simplistic: We will take care of the instantiation of this class, the input, and calling the method for you. All you need to do is write the calculateGrain method in the space provided.

The calculateGrain method takes in 3 integers as input

int width of grain field

int-length of grain field int rainfall this year (in millimeters)

It then makes a simple calculation to determine how much grain fin pounds) will be harvested, and returns the result as an integer The calculation is as follows expectedGrain-width length rainfall/1000)

The value of expectedGrain is then returned Remember, we want to return an Int so you might need to convert your result to an integer before returning it!

Output The output is already handled for you, tor Sample Input/output you, too. An example is shown below.

Input: (handled for you!)

200

300

1100

Processing for this example:

expectedGrain-200 300 1100/10001-660000 convert 66000 0 to 66000 and retum that value

Output (also handled for you!): Farmer Joe has a grain field with a width of 200 meters and a length of 300 meters

There was about 1100mm of rainfall this year

Farmer Joe can expect about 66000 kilograms of grain this year.

GrainCalculator.java

PoDjavaⒸ

import java.util.Scanner;

New

public class POD (

pulitic static void main(String[] args) {

Scanner input her Scanner (System.in); in width input.nextInt();

int length input.nextInt(); Int rainfall input.nextInt();)

GrainCalculator grainCalculator How GrainCalculator(); In expectedGrain grainCalculator.calculateGrain(width, length, rainfall);

System.out.println("Farmer Joe has a grain field with a width of "width" meters and a length of "length" meters."); System.out.println("There was about "rainfall-"mm of rainfall this year."); System.out.println("Farmer Joe can expect about " expectedGrain" kilograms of grain this year."); 

Please give proper explanation and typed answer only.

 

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT