A method named calculateAverageTreeCrown that will accept two double values (sma
ID: 3751097 • Letter: A
Question
A method named calculateAverageTreeCrown that will accept two double values (smallest crown and largest crown) and return their average as a double.
A method named calculateBigTreePoints that will accept three parameters (circumference, height, average crown spread, in that order) and return the points as a double based on the formula above. The parameters types will be String or double.
A method named displayReport that will accept six parameters (common name, scientific name, circumference, height, average crown spread, and points, in that order) and display the following Big Tree report, but return nothing. The parameter types will be String or double.
Code is not compiling and I don't understand why
public class BigTree {
public static double calculateAverageTreeCrown(double smallestCrown, double largestCrown ){
return((smallestCrown + largestCrown)/2.0);
}
public static double calculateBigTreePoints(double circumference, double height, double average crown spread){
return ((circumfrence + height + average crown spread)/3.0);
}
public static void displayReport(String commonName, String scientificName, double circumference, double height, double average crown spread, double points) {
System.out.println("Big Tree Report: ");
System.out.println("Common Name is" +commonName);
System.out.println("Scientific Name is" +scientificName);
System.out.println("Circumference is" +circumference);
System.out.println("Height is" +height);
System.out.println("Average crown spread is" +average crown spread);
System.out.println("Points is" +points);
}
}
Explanation / Answer
public class BigTree
{
public static double calculateAverageTreeCrown(double smallestCrown, double largestCrown ){
return((smallestCrown + largestCrown)/2.0);
}
// variables can't contain space
public static double calculateBigTreePoints(double circumference, double height, double average_crown_spread){
// variable name of circumference was written wrong
return ((circumference + height + average_crown_spread)/3.0);
}
// variables can't contain space
public static void displayReport(String commonName, String scientificName, double circumference, double height, double average_crown_spread, double points) {
System.out.println("Big Tree Report: ");
System.out.println("Common Name is" +commonName);
System.out.println("Scientific Name is" +scientificName);
System.out.println("Circumference is" +circumference);
System.out.println("Height is" +height);
// variables can't contain space
System.out.println("Average crown spread is" +average_crown_spread);
System.out.println("Points is" +points);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.