Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: nid help for my assignment~urgent

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default nid help for my assignment~urgent

    program should provide the operations:
    • Add a new asset into the array (duplicate entries are not allowed).
    • Search for an asset.
    • Amend the details of an asset.
    • Write-off an asset
    • List details of all assets, each on a different line with line numbering.

    all i have done, but left the write-off asset i cant do it. i tried many way , i use the amend asset method to make a change but failed. any1 mind too help? here my source file.

    import java.util.*;
     
    public class process {
    	static int i = 0;
     
    public static void add(Asset [] a){
    	boolean result = false;
    	boolean ip = false;
    	boolean iq = false;
    	boolean option2 = false;
    	Scanner s = new Scanner(System.in);
    	char option = 'y';
    	String input = " ";
    	int orderNum = 0;
    	double price = 0.0;
     
    	do{
    		do{
    			try{
     
    			System.out.print("Enter the Asset(s) ID: ");
        		input = s.next();
        		s.nextLine();
        		if(i > 0)
        		{
        		for(int h = 0 ; h < i ; h++)
        		{
           			result = (a[h].equals(input));
        		}
        		}else
        			{
        			result = false;
        		}
    			}catch(InputMismatchException e1){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			result = true;
    			}
     
    		}while(result == true);
     
            	System.out.print("Enter the Asset(s) Description : ");
            	String desc = s.nextLine();
     
            	System.out.print("Enter the date of Asset(s) <DD/MM/YYYY>");
            	String date = s.nextLine();
     
            		do{
            		try{
            			System.out.print("Enter the Asset(s) Order Number: ");
            			orderNum = s.nextInt();
            			iq = false;
            			}catch(InputMismatchException e3){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			iq = true;
            		}
            	}while(iq == true);
     
            	do{
            		try{
            			System.out.print("Enter the asset(s) CostPrice : ");
            			price = s.nextDouble();
            			ip= false;
            		}catch(InputMismatchException e2){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			ip = true;
            		}
            	}while(ip == true);
     
        		System.out.print("Enter the Status of Asset(s)(<W - written-off,I - in-use >) : ");
            	String status = s.next();
            	s.nextLine();	
     
            	a[i] = new Asset(input,desc,date,orderNum,price,status);
            	a[i].setStatus(status);
            	i++;
     
            	do{
            		try{
           				System.out.print("Do you want to continue add Asset(s)?<Y/N> ");
            			option = s.next().charAt(0);
            			option2 = false;
            			}catch(InputMismatchException e4){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			option2 = true;
            		}
            	}while(option2 == true);
     
    	}while (option == 'y' || option == 'Y');
    		System.out.print("\n");
    }
     
    public static void update(Asset [] b){
    	boolean comfirm = false,amend = false, equal = false;
    	Scanner s = new Scanner(System.in);
    	int choice3 = 0;
    	String input2 = "";
    	System.out.println("No\tItem Number\tItem Description\tItem price\tItem quantity\n");
       	System.out.print("---------------------------------------------------------------------------\n");
    	for(int y = 0; y <i; y++)
    	{
         		System.out.println((y+1)+"\t"+b[y].getID()+"\t\t"+b[y].getDesc()+"\t\t\t"+b[y].getDate()+
         							"\t\t\t"+b[y].getOrderNum()+"\t\t\tRM"+b[y].getCostPrice()+"\t\t"+b[y].getStatus());
    	}
    	do{
    		try{
    				System.out.print("Enter the Asset(s) ID : ");
         			input2 = s.next();
         			s.nextLine();
         			amend = false;
    				}catch(InputMismatchException e5){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			amend = true;
            		}
            	}while(amend == true);
    		for(int n = 0 ; n < i ; n++)
         		{
         			equal = (b[n].equals(input2));
     
         		if(equal == true)
         		{
         		 do{
         			try{
         				System.out.print("Enter the asset(s) description : ");
    	     		  	String newDesc = s.nextLine();
    	     		    b[n].setDesc(newDesc);	
         				comfirm = true;
         			}catch(InputMismatchException e6){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			comfirm = false;
            		}
            	}while(comfirm = false);
     
         		 do{
         			try{
         				System.out.print("Enter the asset(s) date <DD/MM/YYYY> : ");
    				    String date = s.nextLine();
    				    b[n].setDate(date);
    				    comfirm = true;
         			}catch(InputMismatchException e6){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			comfirm = false;
            		}
            	}while(comfirm = false);
     
         		do{
         			try{
         			    System.out.print("Enter the asset(s) order number : ");
    		     	  	int orderNum = s.nextInt();
    		     	    b[n].setOrderNum(orderNum);	
    		     	    comfirm = true;
         			}catch(InputMismatchException e6){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			comfirm = false;
            		}
            	}while(comfirm = false);
     
         		 do{
         			 try{
         			    	System.out.print("Enter the asset(s) cost price : ");
    	     		  		double costPrice = s.nextDouble();
    	     		        b[n].setCostPrice(costPrice);
    	     		        comfirm = true;
         			}catch(InputMismatchException e6){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			comfirm = false;
            		}
            	}while(comfirm = false);
     
         		do{
         			 try{
         			    	System.out.print("Enter the asset(s) status(<W - written-off,I - in-use >) : ");
    	     		  		String status = s.nextLine();
    	     		        b[n].setStatus(status);
    	     		        comfirm = true;	
    	     		        s.nextLine();
         			}catch(InputMismatchException e6){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			comfirm = false;
            		}
            	}while(comfirm = false);
         	}
         }
    }
     
    public static void search(Asset [] c){
    	boolean comparing = false;
    	boolean search = false;
    	Scanner s = new Scanner(System.in);
    	String input3 = "";
    		do{
    			try{
    				System.out.print("Enter the Asset(s) ID : ");
         			input3 = s.next();
         			search = false;
    				}catch(InputMismatchException e9){
        			System.out.println("Invalid character detect!!!");
        			s.nextLine();
        			search = true;
            		}
            	}while(search == true);	
     
         	System.out.println("No\tAsset(s) No\tAsset(s) Description\tAsset(s) Date\tAsset(s) Order Number\n");
         	System.out.println("Asset(s)Cost Price\tAsset(s) Status\n");
       		System.out.print("---------------------------------------------------------------------------\n");
     
         		for(int j = 0 ; j < i ; j++)
         			{
         				comparing = (c[j].equals(input3));	
         					if(comparing == true)
         					{		
         						System.out.println((j+1)+"\t"+c[j].getID()+"\t\t"+c[j].getDesc()+"\t\t\t"+c[j].getDate()+
         							"\t\t\t"+c[j].getOrderNum()+"\t\t\tRM"+c[j].getCostPrice()+"\t\t"+c[j].getStatus());
         						break;
         					}
         			}
         			if(comparing == false)
         			{
         				System.out.println("No such record occur!!");
         			}
         		System.out.printf("\n");
    }
     
    public static void delete(Asset [] d){
     
            System.out.printf("   "); <------------------------------------- write-off part donno how to do....
    }
     
    public static void display(Asset [] f){
    	System.out.println("No\tAsset(s) No\tAsset(s) Description\tAsset(s) Date\tAsset(s) Order Number\n");
         	System.out.println("Asset(s)Cost Price\tAsset(s) Status\n");
        System.out.print("---------------------------------------------------------------------------\n");
    	for(int m = 0; m <i; m++)
    	{
         System.out.println((m+1)+"\t"+f[m].getID()+"\t\t"+f[m].getDesc()+"\t\t\t"+f[m].getDate()+
         							"\t\t\t"+f[m].getOrderNum()+"\t\t\tRM"+f[m].getCostPrice()+"\t\t"+f[m].getStatus());
    	}
    	System.out.printf("\n");	
    }
     
    public static void exitP(){
    	System.out.println("Program is shuting down.");
    	System.out.println("Exiting...");
       }
     
    }
    Last edited by copeg; July 4th, 2010 at 08:19 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: nid help for my assignment~urgent

    Do you get errors from the program? Please copy and paste them here.

    What is the output of the program supposed to look like?

    Also please use code tags to save the code formatting. You posted code is hard to read.

  3. #3
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: nid help for my assignment~urgent

    Moved this thread as it does not appear to be about Object Oriented programming.

    // Json

Similar Threads

  1. HELP URGENT!!
    By macx234 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 30th, 2010, 08:41 PM
  2. Replies: 1
    Last Post: February 22nd, 2010, 08:20 AM
  3. Need Urgent Help
    By sonai4u in forum Threads
    Replies: 2
    Last Post: February 13th, 2010, 08:24 PM
  4. Urgent Help
    By pb60704 in forum Web Frameworks
    Replies: 7
    Last Post: December 1st, 2009, 03:27 AM
  5. Replies: 1
    Last Post: May 4th, 2009, 06:30 AM