Question: Create a program that keeps track of the following information input by the user: First Name, Last Name, Phone Number, Age Now - let's store

Create a program that keeps track of the following information input by the user:

First Name, Last Name, Phone Number, Age

Now - let's store this in a multidimensional array that will hold 10 of these contacts. So our multidimensional array will need to be 10 rows and 4 columns.

You should be able to add, display and remove contacts in the array. Look down here.

******************************************************************************************************************************************************************************************************************

this code comes close to what I am looking for except that - it stores more than 10 contacts. you can input 100 contacts if you like. I NEED IT TO STORE <= 10 CONTACTS

import java.util.*; public class contact { private String fname;// define fname private String lname; // define lname private String phone; // define phone private int age; // define age public contact() { } public static void main(String args[]) { ArrayList list1 = new ArrayList(); // Create a array of list contact c1=new contact(); // create new contact int choice=0; do { Scanner sc1=new Scanner(System.in); // create scanner object for console input System.out.println("Contact Information Database:"); System.out.println("-----------------Menu--------------:"); System.out.println("1. Add a New Contact"); System.out.println("2. Display Contacts"); System.out.println("3. Remove a Contact"); System.out.println("4. Exit"); choice=sc1.nextInt(); if(choice==1) { contact c=new contact(); Scanner sc=new Scanner(System.in); System.out.println("Enter First Name"); c.fname=sc.nextLine(); // First name input System.out.println("Enter Last Name"); c.lname=sc.nextLine(); // Last Name System.out.println("Enter Phone No"); c.phone=sc.nextLine(); // Phone number System.out.println("Enter Age"); c.age=sc.nextInt(); // Enter Age list1.add(c); } if(choice==2) { System.out.println("------------------------------List of Contact------------------------------"); for(int i=0;i=1 && dlt_sn<=list1.size()) { list1.remove(dlt_sn-1); // remove record from a particulat location } else { System.out.println("Wrong Index"); } } else { System.out.println("No Record Found"); } } if(choice==4) { break; } }while(true); } }

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!