Create the public class Module3 which does the following: 1) Holds a String array, initialized to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create the public class Module3 which does the following: 1) Holds a String array, initialized to size zero. 2) Using an infinite loop (eg. while(true)), prompts the user to enter commands via the console 3) Accepts three different user commands via the console with formats: • list: For each array element, the application will sequentially list its index and String text, with each (index, String) pair separated by a space and printed on separate lines. 1. If the array is size zero, the message "no data found" will be printed 2. Any zero-length Strings will be displayed (as no text) with their index numbers . . . format example: User enters the command "list" output example: If the array contains the three Strings "first", "second", and "", the output should be "O first" on one line and "1 second" on the next and "2" on the last line. update [index] [String]: Changes the String text at the specified index to the specified String text, then gives a confirmation message with the old and new Strings and the index. format example: User enters the command "update 1 blue. output example: Suppose the existing text at index 1 is "second". An appropriate confirmation message would be something like "updated index 1 from second to blue". resize [size]: Rebuilds the String array as a new array with the specified size and copies all existing array elements into any valid indexes in the new array, assigns empty Strings to the others, then prints a confirmation message. Additional Constraints The String array should be an ordinary array, not one of the other Java Collection classes. There will be a substantial penalty for not using an ordinary array. Comments should be provided at the start of the file (.e.. above the class definition) giving the class author's name and the date the program was finished. Beyond that, you may choose how to approach the assignment. Any approach that processes console commands properly is acceptable. For example, you will probably use a Scanner object to receive user input but the instructions do not specify any particular way to use it. No exception handling is required - you may assume that the application user will only enter valid commands. format example: User enters the command "resize 5" action example 1: Suppose the array's size is 3. Then the indexes 0 through 2 will be copied into the new array and indexes 3 and 4 will created as zero-length Strings action example 2: Suppose the array's size is 8. Then the indexes 0 through 4 will be copied into the new array. Indexes 5 through 7 will be discarded. output example: After copying any array data, prints "array resized to size 5. Create the public class Module3 which does the following: 1) Holds a String array, initialized to size zero. 2) Using an infinite loop (eg. while(true)), prompts the user to enter commands via the console 3) Accepts three different user commands via the console with formats: • list: For each array element, the application will sequentially list its index and String text, with each (index, String) pair separated by a space and printed on separate lines. 1. If the array is size zero, the message "no data found" will be printed 2. Any zero-length Strings will be displayed (as no text) with their index numbers . . . format example: User enters the command "list" output example: If the array contains the three Strings "first", "second", and "", the output should be "O first" on one line and "1 second" on the next and "2" on the last line. update [index] [String]: Changes the String text at the specified index to the specified String text, then gives a confirmation message with the old and new Strings and the index. format example: User enters the command "update 1 blue. output example: Suppose the existing text at index 1 is "second". An appropriate confirmation message would be something like "updated index 1 from second to blue". resize [size]: Rebuilds the String array as a new array with the specified size and copies all existing array elements into any valid indexes in the new array, assigns empty Strings to the others, then prints a confirmation message. Additional Constraints The String array should be an ordinary array, not one of the other Java Collection classes. There will be a substantial penalty for not using an ordinary array. Comments should be provided at the start of the file (.e.. above the class definition) giving the class author's name and the date the program was finished. Beyond that, you may choose how to approach the assignment. Any approach that processes console commands properly is acceptable. For example, you will probably use a Scanner object to receive user input but the instructions do not specify any particular way to use it. No exception handling is required - you may assume that the application user will only enter valid commands. format example: User enters the command "resize 5" action example 1: Suppose the array's size is 3. Then the indexes 0 through 2 will be copied into the new array and indexes 3 and 4 will created as zero-length Strings action example 2: Suppose the array's size is 8. Then the indexes 0 through 4 will be copied into the new array. Indexes 5 through 7 will be discarded. output example: After copying any array data, prints "array resized to size 5.
Expert Answer:
Answer rating: 100% (QA)
Below is a simple implementation of the Module3 class in Java import javautilScanner Author Your Name Date February 2 2024 Description This class impl... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
1. European farmer's hold large political power and influence policy to get government protection. Consider the effect of a price floor that increases the free-market price on agricultural products...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Suppose that a product can be sold at split-off for $5,000 or processed further at a cost of $1,000 and then sold for $6,400. Should the product be processed further?
-
The following compound has only one asymmetric carbon. Why then does it have four stereoisomers? CH CH CHCH,CH CHCH Br
-
1 and 2 are supplementary angles. Given the measure of 1, find m2. m/1 = 155
-
Forms are provided in the Working Papers. Obtain the present value factors from the tables in the lesson illustrations. Your instructor will guide you through the following examples. 1. Calculate the...
-
The trial balance columns of the worksheet for Firmament Roofing at March 31, 2014, are as follows. Other data: 1. A physical count reveals only $550 of roofing supplies on hand. 2. Depreciation for...
-
EBiz Limited Company is in need of a program that will automate the payroll process that is done manually
-
For this exercise, we use JTRAIN.RAW to determine the effect of the job training grant on hours of job training per employee. The basic model for the three years is hrsempit = (0 + (1td88t + (2d89, +...
-
SAM'S STORY The story of "Sam" offers a look into what happens when lack of cultural intelligence leads to the resignation of a valued employee. Sam was a typical young man from Nepal. He was raised...
-
Assuming modified accelerated cost-recovery-system depreciation and an economic life of five years, what is the book value after three years of an asset of initial cost P?
-
A student loan of$25,000has a5%interest rate compounded daily. The following table includes repayment information for5-,10-, and15-year plans. If monthly payments of$200are made, how many years are...
-
What are the evolutionary consequences of symbiotic relationships, such as mutualism, commensalism, and parasitism, on the diversification and ecological success of interacting species, and how do...
-
The Victoria Fund, a child welfare fund, received $50,000 in cash in the current year. The donor requires the gift be held in perpetuity and that the income from investing this money may be used for...
-
3. Today is January 1, 2020, and you obtain the following quotes from the Wall Street Journal for several traded Treasury bonds with different maturities and coupon rates. Assume that coupons are...
-
Susan made 5 uniform annual deposits of $5000 in a savings account that earned an interest rate of 15% per year. Her last deposit was made 3 years ago. What is the future value of her savings 15...
-
In your audit of Garza Company, you find that a physical inventory on December 31, 2012, showed merchandise with a cost of $441,000 was on hand at that date. You also discover the following items...
-
Declare a variable of the type defined in Question 8 and initialize it. Data From Question 8 Devise a structure declaration that describes a fish.The structure should include the kind, the weight in...
-
Do the same problem as given in Programming Exercise 1 but do worry about complications such as capitalization, spaces, and punctuation.That is,Madam, Im Adam should test as a palindrome. For...
-
Devise a structure declaration that describes a fish. The structure should include the kind, the weight in whole ounces, and the length in fractional inches.
-
The following selected balance sheet and income statement data were taken from the financial records of The Ventura Company: Required 1. Use the Dupont Model to compute the 2013 through 2016 return...
-
North Company's income statement and comparative balance sheets as of December 31 of 2019 and 2018 follow: During 2019, North sold land for \(\$ 70,000\) cash that had originally cost \(\$ 45,000\)....
-
The Pruitt Company's income statement and comparative balance sheets as of December 31 of 2019 and 2018 follow: During the year, the company sold for \(\$ 15,000\) cash old equipment that had cost...
Study smarter with the SolutionInn App