Problem 2 (name this Lab2_Problem2) The space alien ship burned a crop circle of
ID: 668894 • Letter: P
Question
Problem 2 (name this Lab2_Problem2)
The space alien ship burned a crop circle of a particular diameter. You went out and measured it. Have your program input the diameter in feet. Then, calculate the area of the crop circle in square feet. Convert that value to acres. Then, based on the information in the document at the website below, determine how many corn plants were damaged.
https://store.extension.iastate.edu/Product/pm1885-pdf
28-32K plants per acre; assume 30000 for this problem; 43560 square feet in an acre
You will need a value for in your calculations. Use a named constant this problem, with a value of 3.14159. See Notes 3 on how to create named constants.
Step 1: Follow the instructions for creating a new Java project in Using DrJava.
Step 2: To help you memorize a basic Java program structure at this stage of your learning, type in the standard "public class..." and use the specified name for the class in green above. Add the braces, then public static void main(String[] args);. Make sure you have the proper indentation in place (Allman or K&R).
Step 3: Run your program (Compile, then Run). Debug as needed. It won't do anything yet, but you'll be sure it's at an error-free baseline.
Step 4: Go back to Using DrJava and copy and paste the sections for the project's identification information and the other comments into your emerging program. The developer is you, The description should be related to the lab problem.
Step 5: Decide on the input(s) you will need. Declare your input-capture variable(s) and expression-result variables.
Use a named numeric constant of type double for and assign its value accurate to five digits to the right of the decimal point. Follow the rules in Notes 3 for naming the constant. Also, declare this constant under the "Other Variables" section of the DECLARATIONS section.
Step 6: Obtain the end-user input; store the value(s) to appropriate input-capture variable(s) you previously declared.
Construct the input dialog as follows. In this example, the user types in 40 and presses Enter:
Enter crop circle diameter in feet: 40
Compile and run your program to make sure things work.
Step 7: Perform the calculation(s) to compute the volume of your shape; store it to an expression-result variable.
Step 8: Display the output according to the sample, formatted to the number of decimal places shown in the sample below. Your numbers will vary depending on the input; follow the format though (verbiage, spaces, etc.).
Crop circle diameter: 40 feet
Square feet: 5026.44
Acres: 0.115
Estimated corn plants damaged: 3450
Step 9: Determine, based on Internet research, how many bushels of corn were lost to the damage. There are estimates online that show approximate yields per acre. Based on the acres affected, calculate the monetary loss. Find a reasonable, credible source that quotes the cost per bushel.
For the website you settle on as "the best source," provide a brief description of the site and the web address in a BLOCK COMMENT in your code. Explain why you chose that site over the others out in the cloud. There is no right answer—just find a credible source and explain it in your comments.
Add these lines to the output in Step 8 (the numbers are fictitious and provided solely to help you format your output per the sample:
Estimated number of bushel lost: 3.70
Estimated dollar loss: $15.89
Step 10: Close DrJava and make sure you have a backup.
Explanation / Answer
Below is your code :
Most of part is self explanatory. I've Inserted Comments in code for reference URLs
package chegg;
import java.util.Scanner;
public class Problem2 {
public static void main(String[] args) {
final double pi = 3.14159;
/* Reference for Bushel Per Acre http://cornandsoybeandigest.com/blog/usda-projects-record-2014-crop-production */
final double bushelPerAcre = 158.8;
/* USD Price per Bushel Reference http://ycharts.com/indicators/corn_price */
final double usdPerBushel = 3.80;
int plants = 30000;
double acre, area, diameter, radius, plantDamaged, bushalLost, dollarLoss;
Scanner in = new Scanner(System.in);
System.out.print("Enter crop circle diameter in feet: ");
diameter = in.nextDouble();
radius = diameter/2;
area = pi * radius * radius;
acre = area/43560;
System.out.println();
System.out.println("Area in Acres : " + acre);
plantDamaged = acre * plants;
System.out.println("Total damaged plants : " + plantDamaged);
bushalLost = acre * bushelPerAcre;
System.out.println("Estimated number of bushel lost : " + bushalLost);
dollarLoss = bushalLost * bushelPerAcre;
System.out.println("Estimated dollar loss: $ " + dollarLoss);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.