a simple Android program for a banking system using a spinner and displaying the output:
```java
package com.example.bankingsystem;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private Spinner accountTypeSpinner;
private TextView resultTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Find the spinner and text view
accountTypeSpinner = findViewById(R.id.account_type_spinner);
resultTextView = findViewById(R.id.result_text_view);
// Set up the spinner
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.account_types, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
accountTypeSpinner.setAdapter(adapter);
// Set up the spinner listener
accountTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selectedAccountType = parent.getItemAtPosition(position).toString();
displayBankingInfo(selectedAccountType);
@Override
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing
});
private void displayBankingInfo(String accountType) {
switch (accountType) {
case "Savings Account":
resultTextView.setText("Interest rate: 2.5%\nMinimum balance: $500");
break;
case "Checking Account":
resultTextView.setText("Monthly fee: $5\nNo minimum balance");
break;
case "Certificate of Deposit":
resultTextView.setText("Interest rate: 3.0%\nMinimum deposit: $1,000");
break;
default:
resultTextView.setText("Invalid account type");
```
And here's the corresponding XML layout file (`activity_main.xml`):
```xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://www.schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Account Type:"
android:textSize="18sp"
android:textStyle="bold" />
<Spinner
android:id="@+id/account_type_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp" />
<TextView
android:id="@+id/result_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:textSize="16sp" />
</LinearLayout>
```
the user can select an account type from a spinner, and the corresponding banking information is
displayed in the text view. The available account types are defined in the `account_types` string array
resource.
When the user selects an account type, the `displayBankingInfo()` method is called, which checks the
selected account type and displays the appropriate information in the text view.
You can customize this code further by adding more account types, modifying the displayed information,
or adding additional functionality to the banking system.