Calculate average in java

后端 未结 10 2149
悲哀的现实
悲哀的现实 2020-12-11 07:49

EDIT: Ive written code for the average, but i dont know how to make it so that it also uses ints from my args.length rather than the array

I need to

10条回答
  •  孤城傲影
    2020-12-11 08:03

     System.out.println(result/count) 
    

    you can't do this because result/count is not a String type, and System.out.println() only takes a String parameter. perhaps try:

    double avg = (double)result / (double)args.length
    

提交回复
热议问题