Gift Java
Gift Java
Scanner;
import java.util.Arrays;
int a=sc.nextInt();sc.nextLine();
String b=sc.nextLine();
int c=sc.nextInt();sc.nextLine();
String d=sc.nextLine();
String input=sc.nextLine();
Gift ans1=getLowestPricedGiftByBrand(gifts,input);
if(ans1==null)
else {
System.out.println(ans1.getGiftId());
System.out.println(ans1.getGiftName());
System.out.println(ans1.getPrice());
System.out.println(ans1.getBrand());
else {
System.out.println(ans2.getGiftId());
System.out.println(ans2.getGiftName());
System.out.println(ans2.getPrice());
System.out.println(ans2.getBrand());
int low=Integer.MAX_VALUE;
if(gifts[i].getBrand().equalsIgnoreCase(input))
if(gifts[i].getPrice()<low)
low=gifts[i].getPrice();
}
for (int i = 0; i <gifts.length ; i++) {
if(gifts[i].getPrice()==low)
return gifts[i];
return null;
help=Arrays.copyOf(help,help.length+1);
help[help.length-1]=gifts[i].getPrice();
Arrays.sort(help);
if(help.length<=2)
return null;
int thp=help[help.length-2];
for (int i = 0; i <gifts.length ; i++) {
if(gifts[i].getPrice()==thp)
return gifts[i];
return null;
class Gift
this.giftId = giftId;
this.giftName = giftName;
this.price = price;
this.brand = brand;
this.giftId = giftId;
return giftName;
this.giftName = giftName;
return price;
this.price = price;
return brand;
this.brand = brand;
}
}