루프에서 표준 편차를 계산합니까? 저는 표준 편차를 계산하는 공식을 알고 있습니다. 계산을 위해 사용자 입력을받는 방법을 알고 싶습니다. 나는 프로그래밍에 익숙하지 않으므로 모든 것을 설명하십시오. 또한 표준 편차 공식을 쓰려는 시도에 대한 유감스럽게도 SD를 더 잘 이해하기 위해 노력한 것이 아닙니다. 먼저 코드자바에서 표준 편차를 계산하십시오.
import java.util.Scanner;
public class readFromKeyboard {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String inStr = input.next();
int n;
int i;
int count = 0;
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
double average=0;
int sum;
double deviation = 0;
while (!inStr.equals("EOL")) {
count++;
n = Integer.parseInt(inStr);
min = Math.min(min, n);
max = Math.max(max, n);
System.out.printf("%d ", n);
inStr = input.next();
average += n;
// really bad attempt here
deviation = math.pow(n/average,2) ++/mean sqrt();
}
average = average/count;
System.out.println("\n The average of these numbers is " + average);
System.out.printf("The list has %d numbers\n", count);
System.out.printf("The minimum of the list is %d\n", min);
System.out.printf("The maximum of the list is %d\n", max);
input.close();
}
}
[mcve] 및 [ask]를 참조하십시오. – Mat
Welcome to Stack Overflow! 좋은 질문을하고 좋은 대답을 얻으려면 [SO Question Checklist] (http://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist)를 검토하십시오. –