0% found this document useful (0 votes)
7 views4 pages

College Data Processing Script

The document contains a script that counts students majoring in English and Geography using AWK, and a Java program that manages college information. The Java program allows for the input of college details and provides functionality to find the college with the maximum pincode and search for a college by address. It includes classes for College and methods for searching and finding specific colleges based on given criteria.

Uploaded by

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

College Data Processing Script

The document contains a script that counts students majoring in English and Geography using AWK, and a Java program that manages college information. The Java program allows for the input of college details and provides functionality to find the college with the maximum pincode and search for a college by address. It includes classes for College and methods for searching and finding specific colleges based on given criteria.

Uploaded by

mishra.ayush2919
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

awk 'BEGIN{FS="|"; eco=0; gco=0; IGNORECASE=1}

{
if($3 == "English")
{eco++};
if( $3 == "Geography")
{gco++};
}
END{
if(gco==0 && eco==0){
print "No records found.";}
else{
print "Count of students for English Major = "eco;
print "Count of students for Geography Major = "gco;
}
}'

import java.util.*;
class College
{
private int id,cNo,pcode;
private String name,addr;
public College(int id, int cNo, int pcode, String name, String addr)
{
super();
this.id = id;
this.cNo = cNo;
this.pcode = pcode;
this.name = name;
this.addr = addr;
}
public int getId()
{
return id;
}
public int getContactNo()
{
return cNo;
}
public int getPincode()
{
return pcode;
}
public String getName()
{
return name;
}
public String getAddress()
{
return addr;
}
}

public class Maximum


{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();

College college[] = new College[n];

for(int i=0; i<college.length; i++)


{
int id = sc.nextInt();
sc.nextLine();
String name = sc.nextLine();
int contactNo= sc.nextInt();
sc.nextLine();
String address = sc.nextLine();
int pincode = sc.nextInt();

college[i] = new College(id, contactNo, pincode, name, address);


}
sc.nextLine();
String searchaddress = sc.nextLine();

College res1 = findCollegeWithMaximumPincode(college);


if(res1!=null)
{
System.out.println("id-"+res1.getId());

System.out.println("name-"+res1.getName());
System.out.println("contactNo-"+res1.getContactNo());
System.out.println("address-"+res1.getAddress());
System.out.println("pincode-"+res1.getPincode());
}
else
{
System.out.println("No College found with mentioned attribute");
}

College res2 =searchCollegeByAddress(college,searchaddress);


if(res2!=null)
{
System.out.println("id-"+res2.getId());

System.out.println("name-"+res2.getName());
System.out.println("contactNo-"+res2.getContactNo());
System.out.println("address-"+res2.getAddress());
System.out.println("pincode-"+res2.getPincode());
}
else
{
System.out.println("No College found with mentioned attribute.");
}

public static College findCollegeWithMaximumPincode(College col[])


{
int max=0;
College result =null;
for(int i=0; i<col.length; i++){
if(col[i].getPincode() > max){
result = col[i];
max= col[i].getPincode();
}
}

if(result!=null)
return result;
else
return null;
}
public static College searchCollegeByAddress(College c[],String address)
{
College ans=null;
for(int i=0;i<c.length;i++)
{
if(c[i].getAddress().equalsIgnoreCase(address))
{
ans=c[i];

}
}
if(ans!=null)
return ans;
else
return null;
}
}

You might also like