Answered step by step
Verified Expert Solution
Question
1 Approved Answer
COSC 1336 Project 1: Print Text Patterns The Patterns Class COSC 1336 Project 1: Print Text Patterns The Patterns Class Objectives This is one of
COSC 1336 Project 1: Print Text Patterns
The Patterns Class
COSC 1336 Project 1: Print Text Patterns The Patterns Class Objectives This is one of three major programming projects this semester. You may NOT collaborate on this project. While you may ask for assistance in debugging, this project should be ENTIRELY your own work. Other objectives include Use static methods. Use local variables. Use arithmetic expressions. Use Scanner to input values Use a class constant. Use for loops. Hand-in Requirements All projects and laboratories will be submitted electronically through Canvas. Zip up your entire project directory to submit as the source. (Right click on the project folder and follow Send To > Compressed (zipped) Folder or 7-Zip > Add to "projectl.zip".) The project folder should include the following Patterns.java PatternsOutput.txt Tasks Write a program that prints Project 1 written by YOURNAME and calls two methods l.The first method should print a sequence of text boxes. The drawBox method on p. 32 prints one text box, but your method should print a user-specified number of text boxes from left to right. This method should ask the user to enter the number of boxes, and then print that many text boxes horizontally. 2.The second method should print a t described below. This method should ask the user for the width and the height of the pattern, and then print the corresponding pattern. ional pattern of text tiles Here is an example of what your output should look like (user input is in bold and underlined) Enter number of boxes: 3 Enter width of pattern: 3 Enter height of pattern: 2 /N/V /N/V You can find this text pattern and many others at Details The Console You will need to use Scanner to obtain input from the keyboard. You should declarea class constant of type Scanner named CONSOLE at the beginning of your class; you should storenew Scanner(System.in) in CONSOLE. See examples in the Chapter 2 lecture notes and in the Laboratory 2 assignment. Pattern of Text Boxes The first two lines of code in this method should prompt the user for the number of boxes and input the value from the user. Below, it is assumed that the this value is stored innumBoxes The rest of the code should print the boxes. The pattern of text boxes consists of 4 lines. In your program, you will need a for-loop to print each line. The following is the pseudocode for printing the first line Pseudocode for Printing the First Line of the Boxes 1. Print"+" (a plus sign) 2. For each value of i from 1 to numBoxes A. Print "+" 3. Print "n" (a newline) Note that one and one newline are printed outside the for loop. The remaining 3 for loops follow a similar pattern. (Note: the top and bottom lines are the same; the two lines in the middle are the same as well. You may use additional methods to simplify your program.) Two-Dimensional Pattern of Text Tiles The first four lines of code in this method should prompt the user for the width and the height of the pattern and should input the values from the user. Below, it is assumed that the width is stored in width and the height is stored in height. The rest of the code should print the pattern. Note that there are 3 lines of 'X' for the pattern with the height of 2. That is, the lines of 'X' is one more than the pattern height. Therefore, you can print the first line of X; then, each row of the pattern will be identical. This suggests the following pseudocode Pseudocode for Printing the Pattern of Text Tiles 1. Print first line of 'X' 2. For each value of i from 1 to height: A.Print one row of the diamond shape with V and ''; B. Print the bottom line of 'X'. Each of the 3 Print steps above can be implemented by a for -loop with width, two of the for loops are inside the for loop described in the above pseudocode where Consider the pseudocode for printing the first line for one row of the diamond shape Pseudocode for Printing the first line of one row of the diamond shape: 1. For each value of j from 1 to width A. Print"/". 2. Print "n" (a newline) Note that printing a backslash requires an escape sequence. The for loops for printing the other three lines of the diamond shape follow a similar pattern. Rubric [Points] If your program has a method that correctly prints a sequence of text boxes horizontally [Points] For prompting the user for the number of boxes and inputting the value from the user [Points] For for-loops that correctly print the top (and bottom) lines of the boxes. [Points] For for-loops that correctly print the middle lines of the boxes. [Points] If your program has a method that correctly prints a two-dimensional pattern of text tiles [Points] For prompting the user for two numbers (the width and the height) Points] For a for-loop that correctly prints the line of 'X. [Points] Two for-loops that correctly print the top two lines of diamond shape [Points] Two for-loops that correctly print the bottom two lines of diamond shape [Points] For a for-loop that correctly controls the code to print the correct number of line pairs. [Points] .If the main method of your program prints "Project 1 written by [..]" and calls the two other methods. If your submission was a Zip file named project1.zip containing a folder If your Java program was in a file named Patterns.java. If the output of your Java program was in a file named PatternsOutput.txt. If your program contains a comment that describes what the program does and contains a descriptive comment for each method. If your program is indented properlyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started