Hello sir's/ma'am ,i'm new to Arrays and i got an assignment to do but i'am having a problem in arrays and how to input a String...
here's my code.
import java.util.Scanner;
import java.io.*;
class AddressBook
{
public static void main(String[]args)
{
Scanner in = new Scanner(System.in);
Scanner ch = new Scanner(System.in);
String[] name = new String[1024];
int ctr = 0;
int choice;
char choice2;
String exit = " Thank you for using my program ";
String menu = " WELCOME TO JOSEPH JENAIRE PUMARAS ADDRESS BOOK";
System.out.printf("\t\t%s",menu);
do{
System.out.print("\n[1]Add Person");
System.out.print("\n[2]Report ");
System.out.print("\n[3]Exit ");
System.out.print("\nEnter your choice :");
choice = in.nextInt();
switch(choice)
{
case 1:
System.out.print("Enter Name: ");
name = in.next();
break;
case 2:
for (int i = 0 ; i > ctr ;i++)
{
System.out.println(name[i]);
}
break;
}
System.out.print("Would you like to add again? [Y]Yes / [N]No :");
choice2 = ch.next().charAt(0);
}while(choice != 3);
}
}
The report choice in my main menu is supposed to be for displaying all the names that has been entered.... please help me..