+ 2
Please i need help with this java program
import java.util.Scanner; public class Sample12 { public static void main(String[] args) { float[] scores = new float[15]; float[] ans = new float[15]; float sum , avg, kt; //Declare refrence variable of type Scanner Scanner input = new Scanner(System.in); //Read data into array score for(int y = 0; y < 15; y++) scores[y] = input.nextFloat(); //To compute sum and product for(int i = 0; i < 15; i++) { sum = sum + scores[i]; kt += 1; ans[i] = scores[i] * 3; } avg = sum/kt; //Print results System.out.println("\n\tThe average =" +avg); for(int i=0; i<15; i++) { System.out.println(ans[i]); } } }
3 ответов
0
What is your task here..?
One error I can see is kt is Uninitilized.
Put kt = 0; before loop.
+ 1
Thanks
0
No problem