Question

# Java Code import java.util.Scanner; /** Create two methods as instructed below and then call them appropriately....

Java Code

import java.util.Scanner; /** Create two methods as instructed below and then call them appropriately. Hint: Only one of the methods you create needs to be called from the main method. */

public class LandCalculation

{

public static void main(String[] args)

{

final int FEET_PER_ACRE = 43560; // Number of feet per acre

double tract = 0.0, acres = 0.0;

Scanner keyboard = new Scanner(System.in);

System.out.print("Enter the tract size: ");

tract = keyboard.nextDouble(); // Validate the user's input. while(tract < 1)

{

System.out.print("Tract must be at least 1 square foot. Enter the tract size: ");

tract = keyboard.nextDouble();

}

// Calculate the number of acres.

acres = tract / 43560;

// Display the results. System.out.printf("A tract of land with %,.2f square feet has %,.2f acres.", tract, acres);

}

/** Write a method here that accepts a size (in square feet) of a tract of land The method should return the size (in acres) of that tract of land */ /** Write a void method here that accepts a size (in square feet) of a tract of land The method should print out a message that displays the size of the tract of land in square feet and in acres */

}

end of code.....

Rewrite the Java code so that it adheres to what is asked in the comment section.

Once completed with no errors, it should look like this

Enter the tract size: -1

Invalid input! Tract size must be 1 or greater.

Enter the tract size: 123456

A tract of land with 123,456.00 square feet has 2.83 acres.

CODE:

OUTPUT:

RAW CODE:

import java.util.*;
public class LandCalculation{
public static void main(String[] args){
final int FEET_PER_ACRE = 43560; // Number of feet per acre
double tract = 0.0, acres = 0.0;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the tract size: ");
tract = keyboard.nextDouble(); // Validate the user's input. while(tract < 1)
while(tract < 1 ){
System.out.print("Tract must be at least 1 square foot.\nEnter the tract size: ");
tract = keyboard.nextDouble();
}

// calling methods

acres = Tract_to_Acres(tract); // calling the Tract_to_Acres() method with tract as parameter
System.out.printf("A tract of land with %,.2f square feet has %,.2f acres.", tract, acres); // Display the results.
System.out.println(); // new line

tract_to_acres(tract); // calling the void tract_to_acres() method with tract as parameter
System.out.println(); // new line
}

/** Write a method here that accepts a size (in square feet) of a tract of land The method should return the size (in acres) of
that tract of land **/
static Double Tract_to_Acres(double tract){
double acres = tract / 43560 ; // Calculate the number of acres
return (acres);
}
/** Write a void method here that accepts a size (in square feet) of a tract of land The method should print
out a message that displays the size of the tract of land in square feet and in acres **/
static void tract_to_acres(double tract){
double acres = tract / 43560 ; // Calculate the number of acres
System.out.printf("A tract of land with %,.2f square feet has %,.2f acres.", tract, acres); // Display the results.
}
}

NOTE:
If You have any doubts feel free to comment in comment section.
DO VOTE(LIKE).