Home /
Expert Answers /
Computer Science /
need-help-with-the-green-text-part-in-java-thank-you-nbsp-public-static-void-updatecontac-pa635
(Solved): Need help with the green text part in java
Thank you
public static void updateContac ...
Need help with the green text part in java
Thank you
public static void updateContact(ArrayList contactList, Scanner scnr) \{ \( / / \) declare variables Contact contactToFind, contactToUpdate; int indexToUpdate; boolean success; String firstName, lastName, newPhone; System.out.print("Enter the first name: "); firstName = scnr.nextLine(); System.out.print("Enter the last name: "); lastName = scnr.nextLine(); // instantiate a new Contact object "contactToFind" using the first and last name \( / / \) you will use the second constructor from Contact here \( / / \) ** your code here (one line) // use an ArrayList method to \( / / \) find the location (index) of the contact in the list \( / / \) ** your code here (one line)
I/ (index == - 1) \{ System.out.println("Contact not found"); \} else \( \{/ / \) the contact was found \( \quad / / \) use an Arraylist method to \( \quad / / \) find the actual Contact object using the index \( \quad / / \) hold on to the return object in the variable "contactToupdate" \( / / \) get the new phone number from the user \( / / \) update the phone number using the setPhone method \( / / \) to your code here (multiple lines) // if all works out this line should display the contact with a new phone number System.out.println("Updated Contact Info:" + contactToUpdate); 3 3
\( 1 \Theta \) import java.io.FileInputStream; 2 import java.io.FileOutputStream; 3 import java.io. IOException; 4 import java.io.Printwriter; 5 import java.util.Arraylist; 6 import java.util.Arrays; 7 import java.util.Objects; 8 import java.util.Scanner; 9 import java.util.Iterator; 10 11 public class ArrayListPhoneContactsApp \{