I'm a beginner in Java programming. i'm learning from a video tutorial on youtube. i was trying to cre8 array to calcul8 the probability of outcomes on throwing dice. Please tell me where i'm going wrong.
the error message i get is
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The operator /= is undefined for the argument type(s) float[], float
at arrayprac.probability(arrayprac.java:30)
at arrayprac.main(arrayprac.java:18)
import java.util.Random; import java.util.Scanner; public class arrayprac { public static void main(String args[]) { Scanner scan= new Scanner(System.in); Random dice=new Random(); int frequency[]=new int[7]; float probability[]=new float[7]; System.out.println("Enter the sample size"); int sample=scan.nextInt(); for(int counter=0;counter<sample;counter++) { ++frequency[1+dice.nextInt(6)]; } System.out.println("Face\tFrequency\tProbability"); probability(probability,sample); for(int face=1;face<=6;face++) { System.out.println(face + "\t" + frequency[face] + probability[face]); } } public static void probability(float x[], float s) { for(int element=0;element<=x.length;element++) { x/=s; } } }