Advertisement
Guest User

Untitled

a guest
May 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.11 KB | None | 0 0
  1. public static void searchItem() {
  2.         String n = JOptionPane.showInputDialog("Enter name to search:");
  3.         String msg = "";
  4.         boolean found = false;
  5.         for(int i=0;i<rb.length;i++)
  6.         {
  7.             if(rb[i].name.equalsIgnoreCase(n))
  8.             {
  9.                 feature p = (feature) rb[i];
  10.                 msg = "Product Name: " + p.name;
  11.                 msg += "\n" + "Product Number: " + p.number;
  12.                 msg += "\n" + "Number of Product in Stock: " + p.quantity;
  13.                 msg += "\n" + "Item Price: " + new java.text.DecimalFormat("$0.00").format(p.price);
  14.                 msg += "\n" + "Item Restock Fee: " + new java.text.DecimalFormat("$0.00").format(p.restockFee());
  15.                 msg += "\n" + "Inventory Value: " + new java.text.DecimalFormat("$0.00").format(p.InventoryValue());
  16.                 JOptionPane.showMessageDialog(null, msg);
  17.                 found = true;
  18.                 break;
  19.             }
  20.         }
  21.        
  22.         if (found == false) {
  23.             JOptionPane.showMessageDialog(null, "Not found");
  24.             return;
  25.         }
  26.        
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement