You are on page 1of 3

awk 'BEGIN{FS=",";total=0;IGNORECASE=1;}

{
if($3=="finance")
total=total+$4;
}
END{
if(total==0)
print"No Asset Found";
else
print"Total Asset Price = "total;
}'
=================================================
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {


public static void main(String[] args) throws Exception{
//Enter your Code here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Player[] p = new Player[n];
for(int i=0;i<p.length;i++)
{
int id =sc.nextInt();
int matchesPlayed = sc.nextInt();
int totalRuns = sc.nextInt();sc.nextLine();
String name = sc.nextLine();
String team = sc.nextLine();
p[i] = new Player(id, matchesPlayed, totalRuns, name, team);
}
int id1 = sc.nextInt();
Player res1 = findPlayerWithMinimumMatchesPlayed(p);
if(res1 == null)
{
System.out.println("No Player found with mentioned attribute");
}
else
{
System.out.println("id-" + res1.getId());
System.out.println("matchesPlayed-" + res1.getMatchesPlayed());
System.out.println("totalRuns-" + res1.getTotalRuns());
System.out.println("name-" + res1.getName());
System.out.println("team-" + res1.getTeam());
}
Player res2 = searchPlayerById(p, id1);
if(res2 == null)
{
System.out.println("No Player found with mentioned attribute");
}
else{
System.out.println("id-" + res2.getId());
System.out.println("matchesPlayed-" + res2.getMatchesPlayed());
System.out.println("totalRuns-" + res2.getTotalRuns());
System.out.println("name-" + res2.getName());
System.out.println("team-" + res2.getTeam());
}

public static Player findPlayerWithMinimumMatchesPlayed(Player[] players)


{

Player obj1 = players[0];


int min=players[0].getMatchesPlayed();
for(int i=0;i<players.length;i++)
{

if(min > players[i].getMatchesPlayed())


{

min=players[i].getMatchesPlayed();
obj1=players[i];
}

return obj1;

public static Player searchPlayerById(Player[] players, int id)


{
//Enter your Code here
int c = 0;
Player pObj = null;
for(int i=0;i<players.length;i++)
{
if(id == players[i].getId())
{

pObj=players[i];

}
}

return pObj;

class Player
{
//Enter your Code here
int id;
int matchesPlayed;
int totalRuns;
String name;
String team;
public int getId()
{
return id;
}
public int getMatchesPlayed()
{
return matchesPlayed;
}
public int getTotalRuns()
{
return totalRuns;
}
public String getName()
{
return name;
}
public String getTeam()
{
return team;
}
public void setId(int id)
{
this.id = id;
}
public void setMatchesPlayed(int matchesPlayed)
{
this.matchesPlayed = matchesPlayed;
}
public void setTotalRuns(int totalRuns)
{
this.totalRuns = totalRuns;
}
public void setName(String name)
{
this.name= name;
}
public void setTeam(String team)
{
this.team = team;
}
Player(int id, int matchesPlayed, int totalRuns, String name, String team)
{
this.id = id;
this.matchesPlayed = matchesPlayed;
this.totalRuns = totalRuns;
this.name = name;
this.team = team;
}
}

You might also like