Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

CODE

public class activity {

        public static void main(String[] args) {

            int[] rating = {8, 9, 4, 5, 6, 3, 7, 5, 5, 3, 3, 4, 6, 4, 7, 2, 8, 5, 1, 4, 8, 4, 9, 2, 5, 4, 8, 5, 7, 3, 8, 4, 9, 5, 5, 
3, 4, 7, 9, 9};

            int[] scale = new int[10];

            float rate = 0;

            for (int i: rating) {

                scale[i - 1] += 1;

                rate+=  i;

            }

            float average = rate/ 40;

            for (int num = 0; num < scale.length;num++ ){

                System.out.println("The num of " + (num + 1) + " ratings is " + scale[num] + " .");

            }

            System.out.println("The average food ratings is " + average);

        }

    }

OUTPUT SCREENSHOT

You might also like