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..."); } }