Program to average Sale of the Week.

import java.io.*;
class Exp7_1
{
public static void main(String[] args)
{
float sale[] = new float[7];
float avg,sum=0;
try
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.println("Enter Apple Sales for :");
for(int i=0;i<7;i++)
{
System.out.print("Day " +(i+1) +" : ");
sale[i] = Float.parseFloat(br.readLine());
sum = sum+sale[i];
}
avg = sum/7;
System.out.println("Average Apple Sale of the Week : "+avg);
}
catch(Exception e)
{
System.out.println("IOException!");
}
}
}

No comments:

Post a Comment