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

JAVA PROGRAMMING ASSIGNMENT 12

taylorsmallory
taylorsmallory 


Lab Assignment This lab assignment will ask you to write a program using an ArrayList. Exercise 1 1. Create a New Java Application named ArrayListDemo and copy the file ArrayListDemo.java into the project. 2. Compile and run the program. 3. Modify the program so that it asks the user to input a String after the list has been input and tells the user if that String exists in the list. 4. Modify the program so that if the String in 3 has been found, it asks the user to input another String and it replaces the original String with the new String. Print out the list after the String has been replaced. Sample output: Enter items for the list, when prompted. Type an entry: Alice More items for the list? yes Type an entry: Bob More items for the list? yes Type an entry: Carol More items for the list? no The list contains: Alice Bob Carol Enter a String to search for: Bob Enter a String to replace with: Bill Bob found! The list contains: Alice Bill Carol Sample output: Enter items for the list, when prompted. Type an entry: Alice More items for the list? yes Type an entry: Bob More items for the list? yes Type an entry: Carol More items for the list? no The list contains: Alice Bob Carol Enter a String to search for: Bill Bill not found! The list contains: Alice Bob Carol Submit a document with the source code and sample output Attachments
Tags
Clarifications

Answers

JAVA PROGRAMMING ASSIGNMENT 12 - Solution

dickersonka
dickersonka 



Attached is the solution to the JAVA PROGRAMMING ASSIGNMENT 12 assignment including source and comments Attachments
ArrayListDemo.java (1 K) Download Preview
a match if(matchIndex == -1){ System.out.println(searchString + " not found"); } else{ //prompt for string to replace with System.out.println(searchString + " found"); System.out.println("Enter a string to replace with"); String replaceString = keyboard.nextLine(); //replace string in list toDoList.set(matchIndex, replaceString); }

ArrayListDemo_Screenshot.png (10 K) Download Preview

Screenshots
Screenshot
Purchase Answer

JAVA PROGRAMMING ASSIGNMENT 12 - Solution

mariobeka
mariobeka 



Java file and comments. Attachments
ArrayListDemo.java (1 K) Download Preview
= 0; index < listSize; index++) { // check if todolist contains the input string if (toDoList.contains(searchString)) { System.out.println("Enter a String to replace with:"); String replaceString = keyboard.nextLine(); System.out.println(searchString+" Found!"); toDoList.get(index); toDoList.set(index, replaceString); break; // break the for the loop } else { System.out.println(searchString+" not Found!"); break; } }

Screen Shot 2014-05-05 at 9.49.36 PM.png (51 K) Download Preview

Screen Shot 2014-05-05 at 9.50.08 PM.png (48 K) Download Preview

Screenshots
Screenshot
Screenshot
Purchase Answer