From 45d9ed08137a3403cb5999f84cd22c4ec44e887c Mon Sep 17 00:00:00 2001 From: Manjunadh bhavaraju <161492906+BMN5@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:31:06 +0530 Subject: [PATCH] corrected logic to find second highest priced footwear getSecondHighestPriceByBrand() method is not implemented correctly. Currently, it simply returns the first footwear whose brand matches: for(int i =0; i --- IPA2/footwearProgram.java | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/IPA2/footwearProgram.java b/IPA2/footwearProgram.java index 01ad07e..348ea8f 100644 --- a/IPA2/footwearProgram.java +++ b/IPA2/footwearProgram.java @@ -61,18 +61,39 @@ public static int getCountByType(Footwear[] ft, String t) return 0; } } - - public static Footwear getSecondHighestPriceByBrand(Footwear[] ft, String name) - { - for(int i =0; i highest.getPrice()) + { + secondHighest = highest; + highest = ft[i]; + } + else if(secondHighest == null || ft[i].getPrice() > secondHighest.getPrice()) + { + secondHighest = ft[i]; + } } } - return null; + + return secondHighest; } + // public static Footwear getSecondHighestPriceByBrand(Footwear[] ft, String name) + // { + // for(int i =0; i