TQC-101 計算到期金額
這是TQC的101題,
程式碼為自行撰寫,
僅供參考。
主要是練習排版、按鈕事件,
在「eclipse」增加畫面元件時,
可用按右鍵選「EditID」、「EditText」非常方便。
package COM.TQC.GDD01;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class GDD01 extends Activity {
/** Called when the activity is first created. */
private EditText edittext1,edittext2,edittext3;
private Button btn1;
private TextView result;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findview();
setlister();
}
public void findview()
{
edittext1=(EditText)findViewById(R.id.editText1);
edittext2=(EditText)findViewById(R.id.editText2);
edittext3=(EditText)findViewById(R.id.editText3);
result=(TextView)findViewById(R.id.textView4);
btn1=(Button)findViewById(R.id.btn1);
}
public void setlister()
{
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
double d1=Double.parseDouble(edittext1.getText().toString());
double d2=Double.parseDouble(edittext2.getText().toString());
double d3=Double.parseDouble(edittext3.getText().toString());
double r1=Math.pow((1+(d3/100/12)), d2);
double f1=r1*d1;
result.setText(String.valueOf(f1));
}
});
}
}
自我LV~