Question: the code was used for arrays list, can someone help me these code to be arrays of Objects and the program for flowchart. [please do

the code was used for arrays list, can someone help me these code to be arrays of Objects and the program for flowchart. [please do with arrays of object and flowchart].

/** * Write a description of class User here. * * @author () * @version (arraysOfObjects on 11/15/2017) */ import java.util.Scanner; public class User { Scanner in = new Scanner(System.in); private String first, last, phone, email; public User(String f, String l, String p, String e) { first = f; last = l; phone = p; email = e; } @Override

public String toString() { return "User [first=" + first + ", last=" + last + ", phone=" + phone + ", email=" + email + "]"; } public String getFirst() { return first; } public void setFirst(String first) { this.first = first; } public String getLast() { return last; } public void setLast(String last) { this.last = last; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } }

public static void main(String args[]) { Scanner in = new Scanner(System.in);

ArrayList users = new ArrayList();

String choice;

do { System.out.println("Enter the first name");

String first = in.nextLine();

System.out.println("Enter the last name");

String last = in.nextLine();

System.out.println("Enter the phone number");

String phone = in.nextLine();

System.out.println("Enter the email address");

String email = in.nextLine();

System.out.println("Do you want to continue (y/n):");

User u = new User(first, last, phone, email);

users.add(u);

choice = in.nextLine();

} while(choice.equals("y"));

System.out.println("Enter the first name to search in the array:");

String key = in.nextLine();

int flag = 0,i;

for(i = 0; i < users.size(); i++) { User u = users.get(i); if(u.getFirst().equals(key)) { flag = 1; break; } } if(flag == 0)

System.out.println("Given user is not found");

else { User u = users.get(i);

System.out.println("Given user is found");

System.out.println("First name is " + u.getFirst());

System.out.println("Last name is " + u.getLast());

System.out.println("Phone number is " + u.getPhone());

System.out.println("Email id is " + u.getEmail()); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!