0% found this document useful (0 votes)
7 views

Programs

Uploaded by

cital13694
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Programs

Uploaded by

cital13694
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

9.

public static Book searchBookByTitle(Book[] b, String n)


{
for (int i = 0; i < b.length; i++) {
if(b[i].getTitle().equalsIgnoreCase(n))
{
return b[i];
}
}
return null;
}
public static Book[] findBookWithMaximumPrice(Book[] b)
{
Book[] details = new Book[0];
double max = 0;
for (int i = 0; i < b.length; i++)
{
if(b[i].getPrice()>=max)
{
max = b[i].getPrice();
}
}
for (int i = 0; i < b.length; i++) {
if(b[i].getPrice()==max)
{
details = Arrays.copyOf(details, details.length+1);
details[details.length-1]=b[i];
}
}
if(details.length>0)
{
return details;
}
else{
return null;
}
}
---------------------------------------------------------------------------
8. public static int noOfRoomsBookedInGivenMonth Hotel ob, month

int total = 0;
for(int i=0; i<ob.length; i++){
if(ob[i].getDate().contains(month))
total += ob[i].getRooms();
}
return total;

public static int searchHotelByWifiOption Hotel ob, wifi


Hotel temp = new Hotel[0];
for(int i=0; i<ob.length; i++){
if(ob[i].getWifi().equalsIgnoreCase(wifi))

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;
}
}

when calling above function


for(int i=res.length; i>=0; i--){
System.out.println(....);
}
---------------------------------------------------------------------------

6. public static RRT getHighestPriorityTicket RRT ob[], String val


{
RRT temp[] = new RRT[0];
for(int i=0; i<ob.length; i++){
if(ob[i].getProject().equalsIgnoreCase(val)){
temp = Arrays.copyOf(temp,temp.length+1);
temp[temp.length-1] = ob[i];
}
}
RRT temp;
for(int i=0; i<temp.length; i++){
for(int j=i+1; j<temp.length; j++){
if(ob[i].getPriority() > ob[i].getPriority()){
temp = ob[i];
ob[i] = ob[j];
ob[j] = temp;
}
}
}
return temp[0];
}
---------------------------------------------------------------------------

5. public static int totalNoOFRoomsBooked(Motel ob[], String cabFacility){


int total = 0;
for(int i=0; i <ob.length; i++){
if(ob[i].getCabFacility().equalsIgnoreCase(cabFacility) &&
ob[i].getNoOfRooms() > 5){
total += get[i].getNoOfRooms();
}
}
return total;
}
---------------------------------------------------------------------------
4. public static College findCollegeWithMaximumPincode(College ob[])
{
int max = 0;
for(int i=0; i<ob.length; i++){
if( ob[i].getPincode() > max){
max = ob[i].getPincode();
}
}
for(int i=0; i<ob.length; i++){
if(ob[i].getPincode() == max){
return ob[i];
}
}
}
public static College searchCollegeByAddress(College ob[], String add){
for(int i=0; i<ob.length; i++){
if(ob[i].getAddress().equalsIgnoreCase(add)){
return ob[i];
}
}
}

---------------------------------------------------------------------------
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;
}

public static Student findStudentwithSecondHighestScore(Student ob[]){


double arr[] = new double[0];
for(int i=0; i<ob.length; i++){
if(ob[i].getDayScholar() == false){
arr = Arrays.copyOf(arr,arr.length+1);
arr[arr.length-1] = ob[i].getScore();
}
}
for(int i=0; i<arr.length; i++){
for(int j=i+1; j<arr.length; j++){
if(arr[i] > arr[j]){
double temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
double shs = arr[arr.length-2];
for(int i=0; i<ob.length; i++){
if(ob[i].getScore() == shs)
return ob[i];
}
}
---------------------------------------------------------------------------

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;
}

public static Course[] sortCourseByHandsOn(Course ob[], int handsOn){


Course temp[] = new Course[0];
for(int i=0; i<ob.length; i++){
if(ob[i].getHandsOn() < handsOn){
temp = Arrays.copyOf(temp,temp.length+1);
temp[temp.length-1] = ob[i];
}
}
for(int i=0; i<temp.length; i++){
for(int j=i+1; j<temp.length; j++){
if(temp[i].getHandsOn() > temp[j].getHandsOn()){
Course obj = temp[i];
temp[i] = temp[j];
temp[j] = obj;
}
}
}
return temp;
}

You might also like