Question: You will write a single Java program, PA1.java (the filename has to be EXACTLY PA1.java. Points will be deducted if you submit file with any
You will write a single Java program, PA1.java (the filename has to be EXACTLY PA1.java. Points will be deducted if you submit file with any other name), that must:
Prompt for and receive the Common Name of the tree. The prompt must be of the form, "Enter the name: " and the cursor must remain on the line beside the space following the colon.
Prompt for and receive the Scientific Name of the tree. The prompt must be of the form, "Enter the scientific name: " and the cursor must remain on the line beside the space following the colon.
Prompt for and receive the Circumference of the tree. The prompt must be of the form, "Enter the circumference in inches: " and the cursor must remain on the line beside the space following the colon.
Prompt for and receive the Height of the tree. The prompt must be of the form, "Enter the height in feet: " and the cursor must remain on the line beside the space following the colon.
Prompt for and receive the largest Crown Spread of the tree. The prompt must be of the form, "Enter the largest crown spread in feet: " and the cursor must remain on the line beside the space following the colon.
Prompt for and receive the narrowest Crown Spread of the tree. The prompt must be of the form, "Enter the smallest crown spread in feet: " and the cursor must remain on the line beside the space following the colon.
Calculate the Average Crown Spread of the tree.
Calculate the points value for the tree using the formula: Total Points = Trunk Circumference (inches) + Height (feet) + 1/4 * Average Crown Spread (feet)
Output a report in the following format:
public class PA1 { public static void main(String args[]) {
String name; int circumference; int totalPoints; String scientificName; int height; int largestCrownSpread; int smallestCrownSpread; int averageCrownSpread; Scanner in; in = new Scanner(System.in); System.out.print("Enter the name:"); name = in.nextLine(); System.out.print("Enter the scientific name:"); scientificName = in.nextLine(); System.out.print("Enter the circimference in inches:"); circumference = in.nextInt(); System.out.print("Enter the height in feet:"); height = in.nextInt(); System.out.print("Enter the largest crown spread in feet:"); largestCrownSpread = in.nextInt(); System.out.print("Enter the smallest crown spread in feet:"); smallestCrownSpread = in.nextInt(); averageCrownSpread = (largestCrownSpread + smallestCrownSpread)/2; totalPoints = circumference + height + ((1 * averageCrownSpread)/4); System.out.println("Big Tree Report: " +" " +" Common Name: "+ name +" " +"Scientific Name: " + scientificName + " " +" " +" Circumference: " + circumference + " " +" Height: " + height + " " +" Average Crown: " + averageCrownSpread + " " +" " +" Total points: " + Math.round(totalPoints)); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
