標題:
04/20隨堂測驗
[打印本頁]
作者:
顏子翔
時間:
2019-4-20 10:34
標題:
04/20隨堂測驗
考試101唷,請各位回覆於下方
作者:
黃璽安
時間:
2019-4-20 10:52
package com.tqc.gdd01;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class GDD01 extends Activity
{
TextView tv5;
EditText et1, et2, et3;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv5 = (TextView) findViewById(R.id.textView5);
et1 = (EditText) findViewById(R.id.editText);
et2 = (EditText) findViewById(R.id.editText2);
et3 = (EditText) findViewById(R.id.editText3);
btn = (Button) findViewById(R.id.button);
btn.setOnClickListener(myListener);
}
View.OnClickListener myListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Double money = Double.parseDouble(et1.getText().toString());
Double rate = Double.parseDouble(et2.getText().toString())/12/100;
Double number = Double.parseDouble(et3.getText().toString());
int sum = (int) (money*Math.pow(rate+1, number));
tv5.setText("本利合為:"+sum);
}
};
}
複製代碼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/tv1"
android:id="@+id/textView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/tv2"
android:id="@+id/textView2" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/tv3"
android:id="@+id/textView3" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/tv4"
android:id="@+id/textView4" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText3" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/btn"
android:id="@+id/button" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/textView5" />
</LinearLayout>
複製代碼
[/code]
<resources>
<string name="app_name">GD01</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="tv1">整存整付試算:</string>
<string name="tv2">本金(NT$):</string>
<string name="tv3">年利率(%):</string>
<string name="tv4">存款期數:</string>
<string name="btn">計算本利和</string>
</resources>
複製代碼
作者:
陳思惟
時間:
2019-4-20 10:57
package com.tqc.gdd01;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class GDD01 extends Activity
{
EditText et1,et2,et3;
TextView tv;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et1=(EditText)findViewById(R.id.editText);
et2=(EditText)findViewById(R.id.editText2);
et3=(EditText)findViewById(R.id.editText3);
tv=(TextView)findViewById(R.id.textView5);
btn=(Button)findViewById(R.id.button);
}
public void count(View view){
double out=Double.parseDouble(et1.getText().toString())*Math.pow(Double.parseDouble(et2.getText().toString())/100/12+1,Double.parseDouble(et3.getText().toString()));
tv.setText("本利合為:"+out);
}
}
複製代碼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/t1"
android:id="@+id/textView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/t2"
android:id="@+id/textView2" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/t3"
android:id="@+id/textView3" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/t4"
android:id="@+id/textView4" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText3" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="計算"
android:id="@+id/button"
android:layout_gravity="center_horizontal"
android:onClick="count" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView5" />
</LinearLayout>
複製代碼
<resources>
<string name="app_name">GD01</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="t1">整付整存試算:</string>
<string name="t2">本金:</string>
<string name="t3">年利率:</string>
<string name="t4">存款利率:</string>
</resources>
複製代碼
作者:
陳泓瑜
時間:
2019-4-20 11:02
package com.tqc.gdd01;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import java.util.Map;
public class GDD01 extends Activity
{
EditText et1;
EditText et2;
EditText et3;
Button bt;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et1= (EditText) findViewById(R.id.editText);
et2= (EditText) findViewById(R.id.editText2);
et3= (EditText) findViewById(R.id.editText3);
bt= (Button) findViewById(R.id.button);
tv = (TextView) findViewById(R.id.textView5);
}
public void CALC(View view) {
double x=Double.parseDouble(et1.getText().toString());
double y=Double.parseDouble(et2.getText().toString())/100/12;
double z=Double.parseDouble(et3.getText().toString());
tv.setText("本利和為:"+(int)(x* Math.pow(y+1,z)));
}
}
複製代碼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title"
android:id="@+id/textView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub1"
android:id="@+id/textView2" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub2"
android:id="@+id/textView3" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub3"
android:id="@+id/textView4" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText3" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/button"
android:id="@+id/button"
android:onClick="CALC"
android:nestedScrollingEnabled="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView5" />
</LinearLayout>
複製代碼
<resources>
<string name="app_name">GD01</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="title">整存整付試算:</string>
<string name="sub1">本金(NT$):</string>
<string name="sub2">年利率(%):</string>
<string name="sub3">存款期數:</string>
<string name="button">計算本利和</string>
</resources>
複製代碼
作者:
張健勳
時間:
2019-4-20 11:06
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 {
TextView tv5;
EditText et1, et2, et3;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv5= (TextView) findViewById(R.id.textView5);
et1= (EditText) findViewById(R.id.editText1);
et2= (EditText) findViewById(R.id.editText2);
et3= (EditText) findViewById(R.id.editText3);
btn= (Button) findViewById(R.id.button);
btn.setOnClickListener(myListener);
}
View.OnClickListener myListener=new View.OnClickListener() {
@Override
public void onClick(View v) {
double money=Double.parseDouble(et1.getText().toString());
double rate=Double.parseDouble(et2.getText().toString())/100/12;
double number=Double.parseDouble(et3.getText().toString());
int sum= (int)(money*Math.pow(rate+1,number));
tv5.setText("本利合為:"+sum);
}
};
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2