Programming Tutorials

Calculate average sale of the week in Java

By: Paawan Chaudhary in Java Tutorials on 2012-09-19  

This java program accepts value of apple sales for each day of the week (using array of type float) and then, calculates the average sale of the week.

import java.lang.*;
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(;
		for(int i=1;i<=7;i++)
			System.out.println ("Enter sales for day"+i+" of week =");
			sales[i-1] = Float.parseFloat(br.readLine());
		System.out.println ("Sum = "+sum);
		System.out.println ("Average sale of week="+avg);

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in Java )

Latest Articles (in Java)