Description about my Solution:
we always supporting formers in real time situations by giving good prices to their crop
formers are our country backbones their crop is our food so we give the good prices for it
according to my code by observation of previous years we give the good prices
by taking average of previous years we do all our code
import java.util.*;
public class solution {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int lastyears=sc.nextInt();
int[] pricesofyear =new int[lastyears];
boolean profit=false;
int sum=0;
for(int i=0;i<lastyears;i++) {
pricesofyear[i]=sc.nextInt();
sum+=pricesofyear[i];
}
double average=sum/lastyears;
System.out.println("Average Price for this year. "+average );
System.out.println("According to last "+lastyears+"years this year price ="+average);
int last=pricesofyear.length-1;
if(average>pricesofyear[last]){
System.out.println("This year formers get profit of"+(average-pricesofyear[last]));
profit=true;
}
else{
System.out.println("This year former lose "+(pricesofyear[last]-average));
}
if(profit){
System.out.println("This year rate is "+average);
}
else{
System.out.print("To provide good rate this year rate for formers is ");
System.out.println(pricesofyear[last]);
}
//
}
}
on 22-02-2021 | "Voting Start & End Date "Apr 12, 2021, 9:00 AMApr 25, 2021, 11:59 PM (Asia/Calcutta)