Results 1 to 2 of 2

Thread: help please

  1. #1
    jendrick is offline Member
    Join Date
    Jun 2009
    Posts
    2
    Rep Power
    0

    Default help please

    Good day,

    can someone help me?

    heres my code:

    Java Code:
    import java.io.*;
    
    	public class Profile
    	{
    	
    		public static void main (String args[])throws IOException {
    		
    		BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
    		
    		
    		String name,bday,add,eadd,func,vf;
    		
    
    		int choice;
    		System.out.println("Select Function \n\n1>Create Profile\n2>View Profile\n3>View All Contacts\n4>Exit");
    		func=br.readLine();
    		choice=Integer.parseInt(func);
    		
    		if(choice == 1)
    		
    		{
    		
    			System.out.println("Name: ");
    			name=br.readLine();
    			System.out.println("Birthday: ");
    			bday=br.readLine();
    			System.out.println("Address: ");
    			add=br.readLine();
    			System.out.println("Email Address: ");
    			eadd=br.readLine();
    			
    			
    			
    		
    		try {
    		
    				BufferedWriter wr= new BufferedWriter(new FileWriter("r:/profile.txt",true));
    				wr.write("Name: "+name+"\n");
    				wr.write("Birthday: "+bday+"\n");
    				wr.write("Address: "+add+"\n");
    				wr.write("Email Adress: "+eadd+"\n");
    				wr.write("\n");
    				
    				wr.close();
    			}
    			catch(IOException f){
    				System.out.println(f);
    			
    			} 
    			
    		}
    		
    		if(choice == 2)
    		
    		{
    		
    			System.out.println("Profile Name: ");
    			vf=br.readLine();
    			
    			
    			try {
    		
    				BufferedReader in= new BufferedReader(new FileReader("r:/profile.txt"));
    				String str;
    				
    				while((str=in.readLine()) != null){
    				System.out.println("\n"+str);
    				
    			}
    			}
    			catch(IOException e){
    				System.out.println(e);
    			
    			}
    			
    		}
    		
    		if(choice == 3)
    		
    		{
    		
    			try {
    		
    				BufferedReader in= new BufferedReader(new FileReader("r:/profile.txt"));
    				String str;
    				
    				while((str=in.readLine()) != null){
    				System.out.println(str);
    				
    			}
    			}
    			catch(IOException e){
    				System.out.println(e);
    			
    			}
    			
    		}
    		
    		if(choice == 4)
    		
    		{ System.exit(0); } 
    					
    }
    }
    help pls.if i choose number 2 or view profile then i'll type the profile name then the personal info of the profile name that i enter will appear.what is the code that? help pls

  2. #2
    jendrick is offline Member
    Join Date
    Jun 2009
    Posts
    2
    Rep Power
    0

    Default

    whoa i got it..

    Java Code:
     import java.io.*;
    public class Prof{
    public static void main(String[]args) throws IOException
    {
    
    
    BufferedReader JEnDRIck = new BufferedReader(new InputStreamReader(System.in));
    int JENdRicK,count = 4;
    do{
    System.out.println("\nSelect Function\n1>Create Profile\n2>View Profile\n3>View All Contacts\n4>Exit");
    JENdRicK = Integer.parseInt(JEnDRIck.readLine());
    			if(JENdRicK== 1){
    						try{
    							String JeNDriCk,jEnDRicK,jeNdRICk,JEnDrIcK;
    							System.out.print("Name: ");
    							JeNDriCk=JEnDRIck.readLine();
    							System.out.print("Birthday: ");
    							jEnDRicK=JEnDRIck.readLine();
    							System.out.print("Address: ");
    							jeNdRICk=JEnDRIck.readLine();
    							System.out.print("Email: ");
    							JEnDrIcK=JEnDRIck.readLine();
    							//inserting data in textfile
    							BufferedWriter JEnDRicK = new BufferedWriter(new FileWriter("R:/Profiles.txt",true));
    							JEnDRicK.write("\nName: " +JeNDriCk);	
    							JEnDRicK.close();
    							BufferedWriter JENDRicK = new BufferedWriter(new FileWriter("R:/" +JeNDriCk+ ".txt",false));
    							JENDRicK.write("Name: "+JeNDriCk+"\n");
    							JENDRicK.write("Birthday: "+jEnDRicK+"\n");
    							JENDRicK.write("Address: "+jeNdRICk+"\n");
    							JENDRicK.write("Email: "+JEnDrIcK+"\n");
    							JENDRicK.close();
    							}
    						catch(IOException f){
    											System.out.println(f);
    											}
    							}
    	
    			if(JENdRicK== 2){
    						try{
    							String JeNDriCk;
    							System.out.print("\nEnter Profile Name: ");
    							JeNDriCk=JEnDRIck.readLine();
    							BufferedReader in=new BufferedReader(new FileReader("R:/" +JeNDriCk+ ".txt"));
    								while((JeNDriCk=in.readLine())!=null){
    								System.out.println("\n"+JeNDriCk);
    										}
    							in.close();
    							}						
    							catch(IOException e){
    									System.out.println(e);
    											}
    							}
    	
    				if(JENdRicK== 3){
    						try{
    							BufferedReader in=new BufferedReader(new FileReader("R:/Profiles.txt"));
    							String JenDRICk;
    							while((JenDRICk=in.readLine())!=null){
    							System.out.println(JenDRICk);
    											}
    							in.close();
    							}
    								catch(IOException e){
    								System.out.println(e);
    									}
    								}
    
    				if(JENdRicK== 4){
    				System.exit(0);
    					}
    }while(JENdRicK<count);
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •