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.

By | June 11, 2017

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);
	}
}

 

Author: rabins

Rabins is CEO of R.S. Softwares Private Limited, a software and IT company in Nepal. He runs Nepal's first Internet of Things (IoT) website. He is the owner of RabinsXP who is constantly working for increasing IoT in Nepal. He also builds Android, iOS and Web Apps and crafts beautiful websites. He is also working with various social services. The main aim of Lamichhane is to digitally empower the citizens of Nepal and make the world spiritually sound better both in terms of technology and personal development. RabinsXP is the internet nickname of Rabins Sharma Lamichhane too.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.