Question: *** Overview: In this assignment, you will write a Java program in a file named DrawTrees.java that can generate 1/0 (input/output) sessions such as Sample

*** Overview: In this assignment, you will write a Java program in a file named DrawTrees.java that can generate 1/0 (input/output) sessions such as Sample Session 1 shown below. Note that user input is shown underlined only for easy identification, and is not part of the I/O. You will use the following new Java language elements in your program: parameters for controlling the behavior of a method methods that return a value (non-void methods) a Java Scanner object for getting console input from the user Sample I/O Session 1 Implementation Requirements: Your program will contain the following elements: Enter height: 4 Enter number of segments: 3 In the same way you made the public static class Enter till character: - constant in Lab 2, make a public static Scanner class object connected to the System.in console input device (the keyboard). As a class object 1. it will be in the scope of all the methods in the class, 2. it won't have to be passed as a parameter to all the methods that input data from the keyboard. Define a method named getAttribute with the following header public static int getAttribute(String prompt) This getAttribute method performs exactly and only the 3 tasks described below. 1. Display the prompt parameter that was passed to it. 2. Input an int value from the user. Functionality: You will be 3. Return (not display) the value input by the user in task drawing evergreen trees that are 2. characterized by main() will call getAttribute twice: once to get the the number of segments height of the tree, and again to get the number of the height of the segments segments in the tree. See 3.2 and its Common the fill character used to Programming Error Ignoring the Returned Value section draw the tree for the correct way to call a method that returns a value. Your program should be able to Your program will define another parameterized method reproduce exactly any of the of your own design that is called by main(). sample 1/0 sessions shown in this document, using only the Java Your program will define another parameterized method language elements presented in of your own design that is called by another method that is chapters 1-3 of the textbook not main. main will contain calls to only your methods. That is, no NOTE: Don't miss the WARNING section on the last page. calls to println, next Int, etc. If those calls are within assignment statements that is OK. Sample 1/0 Session 4 Enter height: 10 Enter number of segments: 3 Enter till character: I Sample 1/0 Session 5 Enter height: 4 Enter number of segments: 3 Enter fill character: 9 ### ##### ####### 000 GO000 0000000 000 OOOOO 000000000 00000 0000000 00000000000 O ### +++++ ###### D OOOOOOO ### ## ####### WARNING: Chapter 3 was all about writing and calling methods that accept parameters and/or have non-void return values. Students who solve this lab project without employing these new language elements, as instructed in these specs, will receive no more than 5 total points for this lab. That is, the student will lose all 3 implementation points, and all 2 style points, even if the program runs perfectly Students avoid writing and calling their own methods that accept parameters and/or return non-void values by declaring class-level variables, even though Good Style Specifications say to declare variables at the most restrictive scope possible and/or writing all of the code in main().even though specs say main() should call only other methods that you wrote. # # # # # # #
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
