Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java Programming - ThreeArrayLists.java

jankl
jankl 


Step 1: Index Write a Java GUI application called Index.java that inputs several lines of text and a search character and uses String method indexOf to determine the number of occurrences of the character in the text. This program is not case sensitive and both upper and lower case must be counted for. Output Instructions: To the right of the information icon, is the ouitput string"Number of a's: 3" Step 2: Index2 Write a Java GUI application Index2.java based on the program in Step 1 that inputs several lines of text and uses String method indexOf to determine the total number of occurrences of each letter of the alphabet in the text. Uppercase and lowercase letters should be counted together. Store the totals for each letter in an array, and print the values in tabular format after the totals have been determined. Output Instructions Based on Step 1. The out of the application is listed in the lon gtext field, with each letter and frequency of hte letter on the same line, separted by a tab space. Example is a. 12 b. 1 c. 2 Step 3: ThreeArrayLists Write a program called ThreeArrayLists.java that declares three ArrayList objects referenced by the objects named priceList, quantityList, and amountList. Each ArrayList should be declared inmain() and should be capable of holding a minimum of 10 double-precision numbers. The numbers that should be stored in priceList are 10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, 3.98 . The numbers that should be stored in quantityList are 4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9 4.8. Your program should pass object references to these three ArrayList objects to a method named extend(), which should calculate the elements in the amountListArrayList as the product of the corresponding elements in the priceList and quantityListArrayList, for example, amountList.add(priceList.get(i) * quantityList.get(i)). Afterextend() has put values into the amountListArrayList object, create a method that displays the results of all three lists. Appropriate formatting techniques need to be used to produce a formatted output. Tip: It is a good idea to create two arrays of type double to store the values that correspond to the price and the values that correspond to the quantity, for example: double[] PRICE_ARRAY = { 10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, 3.98 }; double[] QUANTITY_ARRAY = { 4.0, 8.5, 6.0, 7.35, 9.0, 15.3, 3.0, 5.4, 2.9, 4.8 }; Sample program output: 1) 10.62 * 4.0 = 42.48 2) 14.89 * 8.5 = 126.56 3) 13.21 * 6.0 = 79.26 4) 16.55 * 7.35 = 121.64 5) 18.62 * 9.0 = 167.58 6) 9.47 * 15.3 = 144.89 7) 6.58 * 3.0 = 19.74 8) 18.32 * 5.4 = 98.93 9) 12.15 * 2.9 = 35.24 10) 3.98 * 4.8 = 19.1 Attachments
Tags Clarifications

Answers

Java Index, Index2, ThreeArrayList Solution

dickersonka
dickersonka 



Attached is the solution... Attachments
Source.zip (3 K) Download
Preview
private JLabel textLable; private JLabel searchTextLable; private JLabel resultLable; JPanel cntrlPanel; public Index() { jtxContent = new JTextArea(); jtxSearch = new JTextField(1); resultLable = new JLabel("0 occurrence(s) found "); textLable = new JLabel("Enter the text "); searchTextLable =

Preview
} } }; //Search action for button btnSearch = new JButton(searchAction); getContentPane().setLayout(new GridLayout(2, 1)); cntrlPanel = new JPanel(new GridLayout(2, 2, 5, 5)); cntrlPanel.add(textLable); cntrlPanel.add(jtxContent); cntrlPanel.add(btnSearch); getContentPane().add(cntrlPanel); getContentPane().add(resScrol); setBounds(20, 20, 350, 270);

Preview
//Price array double[] PRICE_ARRAY = { 10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, 3.98 }; //Add all prices to array list for(double price : PRICE_ARRAY){ priceList.add(price); } //Quantity array double[] QUANTITY_ARRAY = { 4.0, 8.5, 6.0, 7.35, 9.0,

Screenshots
Purchase Answer