Write a Java program that obtains products' numbers (array named productsl), and allows the user to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Java program that obtains products' numbers (array named productsl), and allows the user to perform array's operations using the following methods: initializeArray() - to initialize the array's elements printArray()- to print array's elements searchArray()- to search and determine if a product exists in the array removeArray()- to remove an array element and display the new array The program also includes: 1. One class named ArrayOperations 2. One instance variable named size Your program should include the following code statements in the ArrayApp class: Ariyoyerstions jeva "Araylop jave import javax. swing. J0ptionPane, 3 public class ArrayApp ( public static void main(String(1 args) { Arryoperations obj- new Arryoperations(); obj.initializeArray(); obj.printárray(); int searcho- Integer 19 porseint(30ptionPane.showImputDialog("Do you want to search for a product? 1- Yes, 2- No")); if (searcho e 1) obj. searcharray(); 12 h4 is int Ramoveo - Integer porseint(30ptionPane. showInputoialog("Do you want to remove a product fron the list? 1- Yes, 2- No")); 1f (Renoveg = 1) { obj.renovearray(); hs A sample run is shown below. Proulers Javadoc Declaration O Console Problens Javaduc Declo alion DCursole Amayhpp (1) (lava Appleation Carhpl.papontplugi Amyen ( ava Applicaton ClesholnzipoeighugrayApp (1 ve Applikaliun CNrstipkpzpuuhe EProblene vadue G Declwation Console Irout Inpul Inoie ? Enter product 1 number? 2102 ? How many products you store includes Enter product o number? f1920 OK Cancel OK Cancel OK Cancel Problems "Javadoc S Declaration B Conecie Problems Javadoe B Dechretion ecoreole AeroslamelvadacDedaratos concole e er: 1120 Peoduct Product 1 nuben 2ez Product 2 urber 30s Product nurber 201 Inpun Input Enter product 2 number? ? Enter product 3 mumber? 9201 3109 ? Da ya wa te saarah rora pr Y 1. Yes, a. OK Cancel ок On Can Cancel Robera lovodos Dlanelior OConsule oees Iadir ateon Conle AnayAnp 1 lava Applanon C pnpoohol ArayAnp e) fava Applration Ceshepoalphu iykop la utCinaiteoolglagisagockpjujupen Products Lst. Product e number: 1120 Product i numbee: 2102 Product 2 number 31e9 Product 3 nunber: 920 Products ise product e number: 1120 Product 1 nunber: 2102 reduct 2 number: jzeg Product 1 nunber: 9201 Products List: Product nunber: 10 Preduct 1 ninteri 2102 Praduct z nunter 11e Product nunber: 1201 Input Mecsage which prodact you want to display Do yos want to namove a product trom the tat? 1-Yen, 2-No The product is avalable in posiion no. 2 2102 OK Cancel OK LOK Ceneet Elskad d Problemsmnidor Beciation uConcole EProbleme lavadoc Declantion console ebeinialeda Aayop ( Seve Applcalioni CUvas Products List: Prodact 6wunber: 11 Prouct 3 nber 2 Product ster: Protuct ) sunber: 2 Products List: Product number: 2126 Produtt 1 nubae 2z Prodoct 2 nunber 3aes Product 3 numper 9201 Product e number: 1128 Product i nunber: 2202 Product 2 nunber: 31e9 Product 3 number: 9201 Updated Products List Mussa : 2 elch prodict yee Ment ta rerovet anterthe incss mnser Product e nunber: 1128 Product 1 nunber: 2182 Product 2 nunber: 9201 Product 3 nunber: e The prodact is ramoved am the OK Cance OK Provide screen shots of your answer and program code. Write a Java program that obtains products' numbers (array named productsl), and allows the user to perform array's operations using the following methods: initializeArray() - to initialize the array's elements printArray()- to print array's elements searchArray()- to search and determine if a product exists in the array removeArray()- to remove an array element and display the new array The program also includes: 1. One class named ArrayOperations 2. One instance variable named size Your program should include the following code statements in the ArrayApp class: Ariyoyerstions jeva "Araylop jave import javax. swing. J0ptionPane, 3 public class ArrayApp ( public static void main(String(1 args) { Arryoperations obj- new Arryoperations(); obj.initializeArray(); obj.printárray(); int searcho- Integer 19 porseint(30ptionPane.showImputDialog("Do you want to search for a product? 1- Yes, 2- No")); if (searcho e 1) obj. searcharray(); 12 h4 is int Ramoveo - Integer porseint(30ptionPane. showInputoialog("Do you want to remove a product fron the list? 1- Yes, 2- No")); 1f (Renoveg = 1) { obj.renovearray(); hs A sample run is shown below. Proulers Javadoc Declaration O Console Problens Javaduc Declo alion DCursole Amayhpp (1) (lava Appleation Carhpl.papontplugi Amyen ( ava Applicaton ClesholnzipoeighugrayApp (1 ve Applikaliun CNrstipkpzpuuhe EProblene vadue G Declwation Console Irout Inpul Inoie ? Enter product 1 number? 2102 ? How many products you store includes Enter product o number? f1920 OK Cancel OK Cancel OK Cancel Problems "Javadoc S Declaration B Conecie Problems Javadoe B Dechretion ecoreole AeroslamelvadacDedaratos concole e er: 1120 Peoduct Product 1 nuben 2ez Product 2 urber 30s Product nurber 201 Inpun Input Enter product 2 number? ? Enter product 3 mumber? 9201 3109 ? Da ya wa te saarah rora pr Y 1. Yes, a. OK Cancel ок On Can Cancel Robera lovodos Dlanelior OConsule oees Iadir ateon Conle AnayAnp 1 lava Applanon C pnpoohol ArayAnp e) fava Applration Ceshepoalphu iykop la utCinaiteoolglagisagockpjujupen Products Lst. Product e number: 1120 Product i numbee: 2102 Product 2 number 31e9 Product 3 nunber: 920 Products ise product e number: 1120 Product 1 nunber: 2102 reduct 2 number: jzeg Product 1 nunber: 9201 Products List: Product nunber: 10 Preduct 1 ninteri 2102 Praduct z nunter 11e Product nunber: 1201 Input Mecsage which prodact you want to display Do yos want to namove a product trom the tat? 1-Yen, 2-No The product is avalable in posiion no. 2 2102 OK Cancel OK LOK Ceneet Elskad d Problemsmnidor Beciation uConcole EProbleme lavadoc Declantion console ebeinialeda Aayop ( Seve Applcalioni CUvas Products List: Prodact 6wunber: 11 Prouct 3 nber 2 Product ster: Protuct ) sunber: 2 Products List: Product number: 2126 Produtt 1 nubae 2z Prodoct 2 nunber 3aes Product 3 numper 9201 Product e number: 1128 Product i nunber: 2202 Product 2 nunber: 31e9 Product 3 number: 9201 Updated Products List Mussa : 2 elch prodict yee Ment ta rerovet anterthe incss mnser Product e nunber: 1128 Product 1 nunber: 2182 Product 2 nunber: 9201 Product 3 nunber: e The prodact is ramoved am the OK Cance OK Provide screen shots of your answer and program code.
Expert Answer:
Answer rating: 100% (QA)
The required code is given below The code for ArrayOperations class import javaxswingJOptionPane public class ArrayOperations int products int size Initialization public void initializeArray sizeInteg... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Write a Java program that simulates car racing, as shown in Figure 16.22(a). The car moves from left to right. When it hits the right end, it restarts from the left and continues the same process....
-
Write a java program that calculates land transfer tax based on the explanation above. Program will take the property value as the input. Program will use multiple if-else statements to calculate...
-
Write a Java program that will compare two numbers. Input Data: Input first integer: 25 Input second integer: 39 Expected Output 25 1= 39 25 < 39 25
-
?Claim: A of adults would erase all of their personalinformation online if they could. A software firm survey of 511randomly selected adults showed that 36 ?% of them would erase allof their pe...
-
How is the book value of a depreciable asset computed? How does a depreciable assets book value change from one accounting period to the next? Discuss the difference between the terms book value and...
-
Let C denote the set of points that are interior to, or on the boundary of, a square with opposite vertices at the points (0, 0) and (1, 1). Let Q(C) = C dy dx. (a) If C C is the set {(x, y) : 0 <...
-
Two machines, each with a service life of \(5 \mathrm{yr}\), have the following cost comparison. If the effective interest rate is \(10 \% / \mathrm{yr}\), which machine is more economical? A B First...
-
First Nation Travel uses the contribution margin income statement internally. First Nations first-quarter results follow. First Nations relevant range is between sales of $100,000 and $700,000. FIRST...
-
If the Federal Reserve Bank is selling huge amounts of "reverse repos" to banks and if they are working hard to influence banks to raise their "Fed Funds Rate," and if they are selling large amounts...
-
Portions of the payroll register for Barney's Bagels for the week ended July 15 are shown below. The SUTA tax rate is 5.4%, and the FUTA tax rate is 0.8%, both of which are levied on the first $7,000...
-
An entity provided the following information during the current year: January 1 December 31 Fair value of plan assets 6,000,000 9,000,000 Projected benefit obligation 4,500,000 5,000,000...
-
Write a program that reads in a sequence of integers and prints both the integer that appears in a longest consecutive run and the length of that run. For example, if the input is 1 2 2 1 5 1 1 7 7 7...
-
Evaluate the expression (Math.sqrt(2) * Math.sqrt(2) == 2).
-
Modify Transition to handle pages with no outgoing links, by filling rows corresponding to such pages with the value 1/n, where n is the number of columns.
-
Write a code fragment to multiply two rectangular matrices that are not necessarily square. Note: For the dot product to be well defined, the number of columns in the first matrix must be equal to...
-
Write a program that takes two positive integers as command-line arguments and prints true if either evenly divides the other.
-
Anna's Coffee Shop purchases inventory for $6,000 by paying $4,000 cash and signing a short-term note payable for $2,000 with its vendor. What is the effect of this transaction on the accounting...
-
The text defined intrinsic value as the value of an asset given a hypothetically complete understanding of the assets investment characteristics. Discuss why hypothetically is included in the...
-
Design an EER schema for a database application that you are interested in. Specify all constraints that should hold on the database. Make sure that the schema has at least five entity types, four...
-
Repeat Programming Project 10 of Chapter 2, but include input checking Display the change only if a valid price is entered (no less than 25 cents, no more than 100 cents, and an integer multiple of 5...
-
Why are normal forms alone insufficient as a condition for a good schema design?
-
(a) Show that the variancecovariance matrix of the disturbances in (9.1) is given by (9.2). (b) Show that the two nonzero block matrices in (9.2) can be written as in (9.3). (c) Show that...
-
Using the Harrison and Rubinfeld (1978) data published in Belsley, Kuh and Welsch (1980) and provided on the Springer website as Hedonic.xls, reproduce Table 9.1. Perform the Hausman test based on...
-
Using the Monte Carlo setup for the unbalanced one-way error component model considered by Baltagi and Chang (1994), compare the various estimators of the variance components and the regression...
Study smarter with the SolutionInn App