import java.util.*; public class steviarasilimvector { public static void main (String[]args) { Scanner scan = new Scanner (System.in); int choose = 0; int phnumber = 0; String address = ""; String name = ""; String phnumber3 = ""; String deletename = ""; Vector<String> name2 = new Vector<String>(); Vector<String> address2 = new Vector<String>(); Vector<Integer> phnumber2 = new Vector<Integer>(); do { System.out.println("================"); System.out.println("| Contact Book |"); System.out.println("================"); System.out.println("1. Add a contact"); System.out.println("2. List all contacts"); System.out.println("3. Delete a contact"); System.out.println("4. Exit"); do { System.out.print("Choose [1..4] : "); choose = scan.nextInt();scan.nextLine(); }while (choose<1 || choose>4); switch (choose) { case 1 : System.out.println("===================="); System.out.println("| 1. Add a contact |"); System.out.println("===================="); do { System.out.print("Input the name [3..20] : "); name = scan.nextLine(); name2.add(name); }while (name.length()<3||name.length()>20); do { System.out.print("\nInput the phone number [must be numeric and max. 10 digits] : "); try { phnumber = scan.nextInt();scan.nextLine(); //int phnumber2.add(phnumber); //vector phnumber3 = ""+phnumber; //string }catch (Exception e) { System.out.println("Sorry, the phone number must be numeric and max. 10 digits..."); scan.nextLine(); } }while (phnumber3.length()<1||phnumber3.length()>10); do { System.out.print("\nInput the address [must be start with \"street\" : "); address = scan.nextLine(); address2.add(address); }while(address.startsWith("street")==false); break; case 2 : { System.out.println("========================"); System.out.println("| 2. List all contacts |"); System.out.println("========================"); for (int i=0;i<address2.size();i++) { System.out.println("No : "+(i+1)); System.out.println("Name : "+name2.get(i)); System.out.println("Phone : "+phnumber2.get(i)); System.out.println("Address : "+address2.get(i)); System.out.println("-----------------------------------------"); System.out.println("Press ENTER to back to Menu..."); } } break; case 3 : System.out.println("======================="); System.out.println("| 3. Delete a contact |"); System.out.println("======================="); System.out.println("Input the name [3..20] : "); deletename = scan.nextLine(); for (int i=0;i<name2.size();i++) { if(deletename.equals(name2.get(i))) { name2.remove(i); address2.remove(i); phnumber2.remove(i); System.out.println("Deleting "+deletename+" succesfully"); break; } } } }while (choose !=4); } }
--- Update ---
here is the error :
G:\stevia\algo algo\steviarasilimvector.java:14: cannot access Vector
bad class file: .\Vector.java
file does not contain class Vector
Please remove or make sure it appears in the correct subdirectory of the classpath.
Vector<String> name2 = new Vector<String>();
^
1 error
Tool completed with exit code 1
anyone please help, this is an assignment. thank you