public class fifth extends Activity {
public void onCreate(Bundle savedInstenceState) {
super.onCreate(savedInstenceState);
setContentView(R.layout.fifthmain);
// 데이터 가져오기
Intent intent = getIntent();
String str1 = intent.getExtras().getString("minimum");
String str2 = intent.getExtras().getString("maximum");
String str3 = intent.getExtras().getString("buy");
String str4 = intent.getExtras().getString("sale");
String str5 = intent.getExtras().getString("value");
TextView min1 = (TextView) findViewById(R.id.min1);
TextView max1 = (TextView) findViewById(R.id.max1);
TextView buy1 = (TextView) findViewById(R.id.buy1);
TextView sal1 = (TextView) findViewById(R.id.sal1);
TextView val1 = (TextView) findViewById(R.id.val1);
// 표시하기
min1.setText("최소 : " + str1);
max1.setText("최대 : " + str2);
buy1.setText("구입 : " + str3);
sal1.setText("판매 : " + str4);
val1.setText("가치 : " + str5);
// 문자를 숫자로 변환
int a = Integer.parseInt(str1);
int b = Integer.parseInt(str2);
int c = Integer.parseInt(str3);
int d = Integer.parseInt(str4);
int e = Integer.parseInt(str5);
// 계산
int f = (a + b) / 2; // 평균
int g = (b - a) / 6; // 표준편차
int h = (d - c) / (d - e); // 가치
// h값에 대응하는 z값 찾기
int z = 0;
if (h < 0.075) {
z = (int) -1.65;
} else if (h < 0.125) {
z = (int) -1.29;
} else if (h < 0.175) {
z = (int) -1.04;
} else if (h < 0.225) {
z = (int) -0.85;
} else if (h < 0.275) {
z = (int) -0.68;
} else if (h < 0.325) {
z = (int) -0.53;
} else if (h < 0.375) {
z = (int) -0.39;
} else if (h < 0.425) {
z = (int) -0.26;
} else if (h < 0.475) {
z = (int) -0.13;
} else if (h < 0.525) {
z = (int) 0;
} else if (h < 0.575) {
z = (int) 0.13;
} else if (h < 0.625) {
z = (int) 0.26;
} else if (h < 0.675) {
z = (int) 0.39;
} else if (h < 0.725) {
z = (int) 0.53;
} else if (h < 0.775) {
z = (int) 0.68;
} else if (h < 0.825) {
z = (int) 0.85;
} else if (h < 0.875) {
z = (int) 1.04;
} else if (h < 0.925) {
z = (int) 1.29;
} else if (h <= 1) {
z = (int) 1.65;
}
final int res = g * z + f;
Button result = (Button) findViewById(R.id.result);
result.setOnClickListener(new Button.OnClickListener() {
private TextView textResult;
@Override
public void onClick(View v) {
textResult.setText(res);
}
});
}
}
책 한권하서 독학하고 있습니다. 컴퓨터 프로그래밍 상식이 하나도 없어 너무 어렵습니다.
사전에 입력해둔 수식에 따라 새로 입력된 변수가 계산되어 버튼을 누르면 결과값을 보여주는 어플을 만들고 있는데
앞 액티비티에서 데이터를 받는데까지는 성공했는데
계산하는 부분과 버튼을 누르면 결과값을 출력하는 부분이 진행이 안됩니다.
책이나 이전 질문들 아무리 찾아봐도 모르겠습니다.
도와주세요..ㅜㅜ