How do I code in java to find the frequency of an average? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I code in java to find the frequency of an average?

How do I code in java to find the frequency of an average? Also I need to know how to find its frequency within the range of the average..

8th Feb 2019, 2:05 PM
trialjoshua
1 Answer
0
int sum = 0; int counter = number1; while(counter <= number2){ sum += counter; counter++; } System.out.println("Sum:\t" + sum); System.out.println("Average:\t" + (sum / (number2 - number1 + 1)); //-------------------------------------------------- sum = 0; counter = number1; do{ sum += counter; counter++; }while(counter <= number2); System.out.println("Sum:\t" + sum); System.out.println("Average:\t" + (sum / (number2 - number1 + 1));
8th Feb 2019, 2:35 PM
ali.natoura
ali.natoura - avatar