Write a program to accept the value of Apple sales for each day of the week (using an array of type float) and then, calculate the average sale of the week.

Write a program to accept the value of Apple sales for each day of the week (using an array of type float) and then, calculate the average sale of the week.

import java.lang.*;
import java.io.*;
class q7Apple
{
	public static void main(String args[]) throws IOException
	{
		double avg;
		float sum=0;
		float sales[]=new float[7];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for(int i=1;i<=7;i++)
		{
			System.out.println ("Enter sales for day"+i+" of week =");
			sales[i-1] = Float.parseFloat(br.readLine());
			sum=sum+sales[i-1];
		}
		System.out.println ("Sum = "+sum);
		avg=sum/7;
		System.out.println ("Average sale of week="+avg);
	}
}

 

Rabins Sharma Lamichhane

Rabins Sharma Lamichhane is senior ICT professional who talks about #it, #cloud, #servers, #software, and #innovation. Rabins is also the first initiator of Digital Nepal. Facebook: rabinsxp Instagram: rabinsxp

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *