I need help to implement MapReducebased java code to calcula
I need help to implement MapReduce-based java code to calculate the count, average, minimum and maximum of each product from a series of numbers given as input in a file. The file contains several entries with the following format: value1 \\t value2 whereby value1 represents the product id, and value2 represents the price. For example the input looks like this:
6 553066
9 790076
5 1551
3 497585
10 129744 ...
The output should list the count, average (as integer), minimum, and maximum per product. For example, the output should look like this:
Product 1: Average = 22342
Product 1: Count = 2342
Product 1: Min = 1346 Product 1: Max = 382389 Product 2: Average = 4344 Product 2: Count = 3691 ...
The output should be stored in output file(s). Your program should work for any dataset containing integer numbers.
Solution
import java.util.*;
import java.lang.*;
import java.ui.*;
class Calculations
{
int prodid[], prodprice[], i, n;
printf(\"Enter Product id & Price\"\ );
scanf(\"%d\",prodid[], prodprice[]);
printf(\"Enter how many products you want to Print:\");
scanf(\"%d\",&n);
for(i=0;i<n;i++)
{
printf(\"The product id and product price are:%d \\t%d\",prodid[i],prodprice[i]);
}
public void min() {
for(i=0;i<n;i++){
printf(\"The MIN Price of the product is:%d\",MIN(prodprice[i]));
}
}
public void max() {
for(i=0;i<n;i++)
{
printf(\"The MAX Price of the product is %d\",MAX(prodprice[i]));
}
}
public void Average() {
for(i=0;i<n;i++) {
printf(\"The AVG of the product is %d\",AVG(prodprice[i]));
}
}
public void Count() {
for(i=0;i<n;i++) {
printf(\"The Count of products is\",strlen(prodid[i]);
}
}
}
class mainclass
{
public static void main(String args[])
{
Calculations cal=new Calculations();
cal.min();
cal.max();
cal.Average();
cal.Count();
}
}

