Guest User

Untitled

a guest
Jul 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public Product CostliestPro(Product[] i){
  2. float max=0;
  3. for(Product b:i)
  4. if(b.getPrice()>max)
  5. max=b.getPrice();
  6. for(Product:i)
  7. if(b.getPrice()==max)
  8. return b;
  9. }
  10.  
  11. public Product CostliestPro(Product[] i){
  12. float max=0;
  13. for(Product b:i){
  14. if(b.getPrice()>max){
  15. max=b.getPrice();
  16. }
  17. }
  18. for(Product b:i){
  19. if(b.getPrice()==max){
  20. return b;
  21. }
  22. }
  23. return null;
  24. }
  25.  
  26. public Product CostliestPro(Product[] i){
  27. float max=0;
  28. Product maxProduct = null;
  29. for(Product b:i){
  30. if(b.getPrice()>max){
  31. max=b.getPrice();
  32. maxProduct = b;
  33. }
  34. }
  35.  
  36. return maxProduct;
  37. }
Add Comment
Please, Sign In to add comment