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

*** 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 fill 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 printin, nextInt, etc. If those calls are within assignment statements that is OK. . . Write the subset of your DrawTrees. Java program that does the following: Declare the class Scanner object connected to the System. in keyboard input stream Implement the getAttribute method as per the requirements described above. Have main call the getAttribute method twice to input A) the value for the height of the tree and B) the number of segments in the tree. For the checkpoint, have main() display those values to confirm everything is working correctly. Your checkpoint should be able to generate the following I/O session, where user input is underlined only for easy identification: Enter height: 3 Enter number of segments: 4 Height - 3 and segments - 4 The last line of output is displayed by main(). That last line will not remain in the final version of the program. It is only here for the checkpoint to confirm that the main () method and the getAttribute() method are communicating with each other properly. End Lab 3 Checkpoint Specs Style Requirements Consult the Good Style Specifications page in the Quick Links module on the Canvas website. All requirements in the As of Lab 1. As of Lab 2 and As of Lab 3 sections are now in effect. More Sample I/O Sessions Sample 1/0 Session 2 Sample I/O Session 3 Enter height: 3 Enter height: 5 Enter number of segments: 5 Enter number of segments: 2 Enter till character: x Enter fill character: ! ! !!!!!!! !!!!!!! XXX xxxxx XXX xxxxx XXXXXXX XXXXX xxxxxxx xxxxxxxxx XXXXXXX XXXXXXXXX XXXXXXXXXXX XXXXXXXXX XXXXXXXXXXX XXXXXXXXXXXXX X X xxxxxxx Sample 1/0 Session 5 Enter height: 4 Enter number of segments: 3 Enter fill character: 9 Sample 1/0 Session 4 Enter height: 10 Enter number of segments: 3 Enter fill character: 1 + ### ##### ###### O 00000 0000000 000 000000000 00000 0000000 OOOOOOOOO 00000000000 D ### +++++ ###### O 0000000 +++++++ 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!