7 669
مشترکین
-824 ساعت
-407 روز
+2030 روز
آرشیو پست ها
import java.util.*;
class Laptop{
private int modelNumber;
private String brand;
private String processorType;
private int ramCapacity;
private int price;
public Laptop(int modelNumber,String brand,String processorType,int ramCapacity,int price){
this.modelNumber=modelNumber;
this.brand=brand;
this.processorType=processorType;
this.ramCapacity=ramCapacity;
this.price=price;
}
public int getModelNumber(){
return modelNumber;
}
public void setModelNumber(int modelNumber){
this.modelNumber = modelNumber;
}
public String getBrand(){
return brand;
}
public void setBrand(String brand){
this.brand = brand;
}
public String getProcessorType(){
return processorType;
}
public void setProcessorType(String processorType){
this.processorType = processorType;
}
public int getRamCapacity(){
return ramCapacity;
}
public void setRamCapacity(int ramCapacity){
this.ramCapacity = ramCapacity;
}
public int getPrice(){
return price;
}
public void setPrice(int price){
this.price = price;
}
@Override
public String toString(){
return "Model-"+modelNumber+"\nBrand-"+brand+"\nPrice-"+price;
}
}
public class Solution{
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
Laptop[] laptop=new Laptop[n];
for(int i=0;i<n;i++) {
int a=scanner.nextInt();
scanner.nextLine();
String b=scanner.nextLine();
String c=scanner.nextLine();
int d=scanner.nextInt();
int e=scanner.nextInt();
laptop[i]=new Laptop(a,b,c,d,e );
}
scanner.nextLine();
String par1= scanner.nextLine();
int par2=scanner.nextInt();
scanner.nextLine();
String par3=scanner.nextLine();
scanner.close();
if(getCountOfLaptopByProcessorTypeAndRamCapacity(laptop,par1,par2)==0) {
System.out.println("No Laptop found with mentioned attribute");
}
else {
System.out.println(getCountOfLaptopByProcessorTypeAndRamCapacity(laptop,par1,par2));
}
if(findLaptopWithSecondHighestPriceByBrand(laptop,par3)==null) {
System.out.println("No Laptop found with mentioned attribute");
}
else {
System.out.println(findLaptopWithSecondHighestPriceByBrand(laptop,par3));
}
}
public static Laptop findLaptopWithSecondHighestPriceByBrand(Laptop[] arr,String brand){
Laptop[] result=Arrays.asList(arr).stream().filter(e->e.getBrand().equalsIgnoreCase(brand)).sorted((s1,s2)->{
return s2.getPrice()-s1.getPrice();
}).toArray(size->new Laptop[size]);
if(result.length<2)
return null;
return result[1];
}
public static int getCountOfLaptopByProcessorTypeAndRamCapacity(Laptop[] arr,String type,int cap){
int tem=0;
for(Laptop var:arr) {
if( var.getRamCapacity()==cap && var.getProcessorType().equalsIgnoreCase(type))
tem++;
}
return tem;
}
}
Amdocs internal Exam✅✅✅
UST FOUNDATIONAL ASSESSMENT CLEARED ✅✅✅
100% CLEARANCE FOR ANY EXAM ✅
go through here 👇
https://t.me/python_java_Coding/8229?single
Contact: @MLCODER2
Walmart,Ninja cart, CTS exam help available✅✅
Contact: @MLCODER2
+4
WIPRO 5/5 slots done successfully✅✅✅
Contact:@MLCODER2
اکنون در دسترس! پژوهش تلگرام ۲۰۲۵ — مهمترین بینشهای سال 
