Programs
Programs
int total = 0;
for(int i=0; i<ob.length; i++){
if(ob[i].getDate().contains(month))
total += ob[i].getRooms();
}
return total;
temp = Arrays.copyOf(temp,temp.length+1);
temp[temp.length-1] = ob[i].getId();
Arrays.sort(temp);
}
return temp[temp.length-2];
---------------------------------------------------------------------------
7. public static Sim[] transferCustomerCircle Sim ob[], circle1, circle2
{
Sim temp[] = new Sim[0]
for(int i=0; i<ob.length; i++){
if(ob[i].getCircle().equalsIgnoreCase(circle1)){
temp = Arrays.copyOf(temp,temp.length+1);
ob[i].circle = circle2;
temp[temp.length-1] = ob[i];
}
}
Arrays.sort(temp); OR USE SORTING ALGO!
if(temp.length>0){
return temp;
}else{
return null;
}
}
---------------------------------------------------------------------------
3. public static findCountOfDayscholarStudents(Student ob[]){
int count = 0;
for(int i=0; i<ob.length; i++){
if(ob[i].getScore() > 80 && ob[i].getDayScholar() == true){
count++;
}
}
return count;
}
2.
public static int getCountByType(Footwear ob[], String fType){
int count = 0;
for(int i=0; i<ob.length; i++){
if(ob[i].getFootwearType().equalsIgnoreCase(fType))
count++;
}
return count;
}
public static Footwear getSecondHighestPriceByBrand(Footwear ob[], String
inputFootwearName){
int arr[] = new int[0];
for(int i=0; i<ob.length; i++){
if(ob[i].getFootwearName().equalsIgnoreCase(inputFootwearName)){
arr = Arrays.copyOf(arr,arr.length+1);
arr[arr.length-1] = ob[i].getPrice();
}
}
Arrays.sort(arr);
int shp = arr[arr.length-2];
for(int i=0; i<ob.length; i++){
if(ob[i].getPrice() == shp)
return ob[i];
}
}
----------------------------------------------------------------------------------
1.
public static int findAvgOfQuizByAdmin(Course ob[], String courseAdmin){
int sum = 0, count = 0;
int avg;
for(int i=0; i<ob.length; i++){
if(ob[i].getCourseAdmin().equalsIgnoreCase(courseAdmin)){
sum += ob[i].getQuiz();
count++;
}
}
avg = sum/count;
return avg;
}