Create a method that, accepting a 2-dimensional array of type char, can produce a box and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create a method that, accepting a 2-dimensional array of type char, can produce a box and display each character drawn from the array within. You must meet the submission deadline and must demo your code on your assigned period to get your marks. Grades: 5% of your final course mark Deadline Submission (September 28th, 11:59 PM.) Demo on your next lab period (September 30, 2022). // Important marking code: if (!submission || Idemo || lateSubmission) { grade = 0; 3 Lab 2-2D Arrays (2).pdf of 5 Q + File | C:/Users/ACER/Downloads/Lab%202-2D%20Arrays%20(2).pdf Type here to search CD Page view A Read aloud Steps Step 1. Create a New Project In this case, there must be only one class file, named Lab2. Case matters, so it may not be "lab2". If you wish to put it in a package, that package must be named "lab2". The main method is provided for you, and you must use it as-is. You may not modify it, except you may change the format and comments. Leave the code itself alone. public static void main(String[] args) { TAdd text This code will call your method, and pass it a 2D array of chars that it has created, of unknown size. Feel free to copy and paste it into your project. Lab2 thisLab = new Lab2 (); int counter=97; //ASCII lowercase a. Random myrand = new Random(); //For random number generation. } int rows = myrand.nextInt (5) +1; char[] [] myArray = new char[rows] []; //Creation of random-height 2D array. } Draw for (int i=0;i 4 Lab 2-2D Arrays (2).pdf of 5 Q + File | C:/Users/ACER/Downloads/Lab%202-2D%20Arrays%20(2).pdf Type here to search O CD Page view A Read aloud Step 2. Method printSquare(char[][] charArray) Create a new method named printSquare, which accepts a 2-dimensional array of chars. Your code must go through the array, creating squares and printing the contents of each cell of the array. As the provided main method generates a different array each time, you will get different results each time you run the code. A few sample runs are below: +-----+ 1 1 I I T I a g 1 I I I h | | d i e f TAdd text Draw Highlight 9C Mostly cloudy Erase {" 67 4x ENG @ 0 11:38 PM 9/28/2022 X 4 Lab 2-2D Arrays (2).pdf of 5 Q + + File | C:/Users/ACER/Downloads/Lab%202-2D%20Arrays%20(2).pdf Type here to search O I A few sample runs are below: I __ a CD Page view bl f I Ia I --- --- A g b --- --- h e A Read aloud T Add text Your code will not "know" any of the dimensions of the array, and must get that information from the array itself, line by line. You will find the last handful of pages in Week 1's lecture notes very helpful for this. Under no circumstances can you assume anything about the array's size. It might even be 0! I may sneak in arrays of different sizes than is provided in main. Your code must be able to handle it. If a given row is zero, print nothing. Don't produce any output at all and continue with the next row. Draw Highlight 9C Mostly cloudy 0 a -> Erase {" 67 4x ENG @ 0 11:38 PM 9/28/2022 X 5 Lab 2-2D Arrays (2).pdf of 5 Q + File | C:/Users/ACER/Downloads/Lab%202-2D%20Arrays%20(2).pdf Type here to search O JU! CD Page view Your code must figure out the maximum width from the array itself and may make no assumptions about its size. I should be able to use any-sized array with this code. A Read aloud Step 3. Submit your Code In the main Brightspace shell, turn in your code. Submit the java file you wrote, in a zip file ONLY. .7z, .rar or other compression formats will result in a penalty. [T] Add text Step 4. Demo your Code In your lab next week, have your code ready to run. I will call upon you in random order. Final Thoughts Few Suggestions In your project, all array sizes must be drawn from the array itself. You may assume nothing about the size of the array at all. I should be able to use an array of any size with your method. Marking Scheme Think of this as a sequence of events. If you confused by the code, show me your thinking. In plain English, write out the operations, step by step, that you would do to solve this problem. Do pay attention to the filename requirements. Your class must be "Lab2". Do not forget your comments! These are easy marks. You can quickly format your code in Eclipse with CTRL+SHIFT+F. It's much easier to debug formatted code. Check Rubric H Draw Highlight 9C Mostly cloudy o a -> Erase {" 67 4x ENG @ 0 11:38 PM 9/28/2022 X Create a method that, accepting a 2-dimensional array of type char, can produce a box and display each character drawn from the array within. You must meet the submission deadline and must demo your code on your assigned period to get your marks. Grades: 5% of your final course mark Deadline Submission (September 28th, 11:59 PM.) Demo on your next lab period (September 30, 2022). // Important marking code: if (!submission || Idemo || lateSubmission) { grade = 0; 3 Lab 2-2D Arrays (2).pdf of 5 Q + File | C:/Users/ACER/Downloads/Lab%202-2D%20Arrays%20(2).pdf Type here to search CD Page view A Read aloud Steps Step 1. Create a New Project In this case, there must be only one class file, named Lab2. Case matters, so it may not be "lab2". If you wish to put it in a package, that package must be named "lab2". The main method is provided for you, and you must use it as-is. You may not modify it, except you may change the format and comments. Leave the code itself alone. public static void main(String[] args) { TAdd text This code will call your method, and pass it a 2D array of chars that it has created, of unknown size. Feel free to copy and paste it into your project. Lab2 thisLab = new Lab2 (); int counter=97; //ASCII lowercase a. Random myrand = new Random(); //For random number generation. } int rows = myrand.nextInt (5) +1; char[] [] myArray = new char[rows] []; //Creation of random-height 2D array. } Draw for (int i=0;i 4 Lab 2-2D Arrays (2).pdf of 5 Q + File | C:/Users/ACER/Downloads/Lab%202-2D%20Arrays%20(2).pdf Type here to search O CD Page view A Read aloud Step 2. Method printSquare(char[][] charArray) Create a new method named printSquare, which accepts a 2-dimensional array of chars. Your code must go through the array, creating squares and printing the contents of each cell of the array. As the provided main method generates a different array each time, you will get different results each time you run the code. A few sample runs are below: +-----+ 1 1 I I T I a g 1 I I I h | | d i e f TAdd text Draw Highlight 9C Mostly cloudy Erase {" 67 4x ENG @ 0 11:38 PM 9/28/2022 X 4 Lab 2-2D Arrays (2).pdf of 5 Q + + File | C:/Users/ACER/Downloads/Lab%202-2D%20Arrays%20(2).pdf Type here to search O I A few sample runs are below: I __ a CD Page view bl f I Ia I --- --- A g b --- --- h e A Read aloud T Add text Your code will not "know" any of the dimensions of the array, and must get that information from the array itself, line by line. You will find the last handful of pages in Week 1's lecture notes very helpful for this. Under no circumstances can you assume anything about the array's size. It might even be 0! I may sneak in arrays of different sizes than is provided in main. Your code must be able to handle it. If a given row is zero, print nothing. Don't produce any output at all and continue with the next row. Draw Highlight 9C Mostly cloudy 0 a -> Erase {" 67 4x ENG @ 0 11:38 PM 9/28/2022 X 5 Lab 2-2D Arrays (2).pdf of 5 Q + File | C:/Users/ACER/Downloads/Lab%202-2D%20Arrays%20(2).pdf Type here to search O JU! CD Page view Your code must figure out the maximum width from the array itself and may make no assumptions about its size. I should be able to use any-sized array with this code. A Read aloud Step 3. Submit your Code In the main Brightspace shell, turn in your code. Submit the java file you wrote, in a zip file ONLY. .7z, .rar or other compression formats will result in a penalty. [T] Add text Step 4. Demo your Code In your lab next week, have your code ready to run. I will call upon you in random order. Final Thoughts Few Suggestions In your project, all array sizes must be drawn from the array itself. You may assume nothing about the size of the array at all. I should be able to use an array of any size with your method. Marking Scheme Think of this as a sequence of events. If you confused by the code, show me your thinking. In plain English, write out the operations, step by step, that you would do to solve this problem. Do pay attention to the filename requirements. Your class must be "Lab2". Do not forget your comments! These are easy marks. You can quickly format your code in Eclipse with CTRL+SHIFT+F. It's much easier to debug formatted code. Check Rubric H Draw Highlight 9C Mostly cloudy o a -> Erase {" 67 4x ENG @ 0 11:38 PM 9/28/2022 X
Expert Answer:
Answer rating: 100% (QA)
Heres the Java code for the Lab2 class that includes the method to find the maximum width of ... View the full answer
Related Book For
Data Modeling and Database Design
ISBN: 978-1285085258
2nd edition
Authors: Narayan S. Umanath, Richard W. Scammel
Posted Date:
Students also viewed these programming questions
-
Commuters In Problems 1-2, find all the 2 x that commute with the given matrix. 2 matrices. 1. Where a ( R 2. Where k ( R, k ( 0 3 0 0 0 0
-
In 2019, Firm X had revenue of $200 million, costs excluding depreciation of $70 million, depreciation expense of $20 million, interest expense of $40 million and capital expenditure of $15 million....
-
A T-account in the table below for a feedlot that places feeder cattle on feed in September. Use the information in Table 8.1 (or the CME Group's website) to determine the appropriate futures...
-
Q2. (20 pts) Product structure tree of product A is given in the following table: B(2) A C(3) D(3) E(4) F(5) E(6) a. How many components of each kind to produce 5 product A? b. Draw operation process...
-
Dallas Company produces joint products, TomL and JimmyJ, each of which incurs separable production costs after the splitoff point. Information concerning a batch produced at a $200,000 joint cost...
-
Use the surface integral in Stokes Theorem to calculate the circulation of the field F around the curve C in the indicated direction. F = x 2 i + 2xj + z 2 k C: The ellipse 4x 2 + y 2 = 4 in the...
-
1. Your instructor will divide the class into teams and assign each team the task of investigating the start-up of one of the following businesses: a. Submarine sandwich shop b. Day care service c....
-
On December 1, 2014, Prosen Distributing Company had the following account balances. During December, the company completed the following summary transactions. Dec. 6 Paid $1,600 for salaries and...
-
distributed database management system, are there any concerns or issues managing distributed database management systems, and if so, why?
-
Bhavika Investments, a group of financial advisors and retirement planners, has been requested to provide advice on how to invest $200,000 for one of its clients. The client has stipulated that the...
-
The model for the IS-LM model is given below. Y = C +1 + G C = C(Y - T, R) I= I(Y, R) T = T(Y) M/P = L(Y, R) A) Find the effect of the increase in government spending on income and interest rate....
-
Operating income for Division A is $520,000, total service department charges are $480,000, and operating expenses are $3,200,000. What are the revenues for Division A?
-
Villanueva Corp. had 200,000 shares of common stock, 20,000 shares of convertible preferred stock, and $1,000,000 of 5% convertible bonds outstanding during 2020. The preferred stock is convertible...
-
How do advanced cost-benefit analysis frameworks and probabilistic decision-making models guide strategic resource allocation decisions, balancing short-term efficiency gains with long-term...
-
On June 1, 20Y2, Herbal Co. received $47,150 for the rent of land for 12 months. Journalize the adjusting entry required for unearned rent on December 31, 20Y2. Round your answers to the nearest...
-
NEGOTIATION 1.There is a client complaining about the product they have received. Your customer told you "The item that you send to me has a lot of damages and it is not what I ordered!"Now, the...
-
One end of a horizontal spring with force constant 130.0 N/m is attached to a vertical wall. A 5.00 kg block sitting on the floor is placed against the spring (the block touches the uncompressed...
-
B.) What is the approximate concentration of free Zn 2+ ion at equilibrium when 1.0010 -2 mol zinc nitrate is added to 1.00 L of a solution that is 1.080 M in OH - . For [Zn(OH) 4 ] 2- , K f = 4.610...
-
Under what circumstances in a specialization is it possible for both one superclass to be related to more than one subclasses and one subclass to be related to one or more superclasses?
-
Describe the two approaches used in this book to derive candidate keys.
-
Describe various data types associated with attributes.
-
Motion pictures and television programs are responsible for a misconception about the way in which trials proceed. Explain.
-
Describe the basic difference between the systems of courts in the United States and in Canada.
-
Explain why a legal rule in one province may differ from that in another province.
Study smarter with the SolutionInn App