Professional Documents
Culture Documents
14 Nov PRA
14 Nov PRA
Write a Unix command to count the number of Snacks with count greater than 25.
Print output in following format:
Total count: <count>
Sample Input 1 :
ID#Name#Count
101#Sweet#22
234#chips#24
341#juice#26
511#chocolates#27
Output : Total count: 2
awk 'BEGIN{FS="#";count=0}
{
if($3>25)
{
count=count+1;
}
}
END{
print"Total count:",count;
}'
This method will take array of Retail objects and Name as input and returns the
Retail object having the mentioned name if found else return null if not found.
4
111 cotton 1000 300.75
222 velvet 500 200.25
334 linen 200 617.79
444 flannel 789 222.65 flannel
package handson;
import java.util.Scanner;
class Retail
{
private int id;
private String name;
private int quantity;
private double price;
public Retail(int id, String name, int quantity, double price) {
super();
this.id = id;
this.name = name;
this.quantity = quantity;
this.price = price;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
public class Solution {