Question: Create an app called MyFinances. The app should allow the storing of financial objects. The financial objects are CDs, Loans, and Checking accounts. CDs should

Create an app called MyFinances. The app should allow the storing of financial objects. The financial objects are CDs, Loans, and Checking accounts. CDs should be able to store the account number, initial balance, current balance, and interest rate. Loans should be able to store the account number, initial balance, current balance, payment amount, and interest rate. Checking accounts should be able to store the account number and current balance. The user should select the type of account to enter with RadioButtons. Selection of the account should enable/disable relevant fields on the data entry activity. Store objects using a database table when the user clicks the Save button. The Save button should also display a saved message and clear the screen. A Cancel button should clear the screen without saving any data.

PROVIDING MainActivity.java file, PLEASE FORMAT XML FILE BASED ON THIS.

Please create the activity_main.xml file IN JAVA. IN JAVA, PLEASE.

import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; import android.widget.Toast; public class MainActivity extends AppCompatActivity { EditText accountNumber, initialBalance, currentBalance, interestRate, paymentAmount; RadioButton cd, loan, checking; Button save, cancel; DatabaseHelper db; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); accountNumber = findViewById(R.id.accountNumber); initialBalance = findViewById(R.id.initialBalance); currentBalance = findViewById(R.id.currentBalance); interestRate = findViewById(R.id.interestRate); paymentAmount = findViewById(R.id.paymentAmount); cd = findViewById(R.id.cd); loan = findViewById(R.id.loan); checking = findViewById(R.id.checking); save = findViewById(R.id.save); cancel = findViewById(R.id.cancel); db = new DatabaseHelper(this); save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String accNum = accountNumber.getText().toString(); String iBalance = initialBalance.getText().toString(); String cBalance = currentBalance.getText().toString(); String iRate = interestRate.getText().toString(); String pAmount = paymentAmount.getText().toString(); if (cd.isChecked()) { if (!accNum.equals("") && !iBalance.equals("") && !cBalance.equals("") && !iRate.equals("")) { boolean insert = db.insertCd(accNum, iBalance, cBalance, iRate); if (insert) { Toast.makeText(getApplicationContext(), "Saved successfully!", Toast.LENGTH_SHORT).show(); clearFields(); } else { Toast.makeText(getApplicationContext(), "Something went wrong!", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please fill all the fields!", Toast.LENGTH_SHORT).show(); } } if (loan.isChecked()) { if (!accNum.equals("") && !iBalance.equals("") && !cBalance.equals("") && !iRate.equals("") && !pAmount.equals("")) { boolean insert = db.insertLoan(accNum, iBalance, cBalance, pAmount, iRate); if (insert) { Toast.makeText(getApplicationContext(), "Saved successfully!", Toast.LENGTH_SHORT).show(); clearFields(); } else { Toast.makeText(getApplicationContext(), "Something went wrong!", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please fill all the fields!", Toast.LENGTH_SHORT).show(); } } if (checking.isChecked()) { if (!accNum.equals("") && !cBalance.equals("")) { boolean insert = db.insertChecking(accNum, cBalance); if (insert) { Toast.makeText(getApplicationContext(), "Saved successfully!", Toast.LENGTH_SHORT).show(); clearFields(); } else { Toast.makeText(getApplicationContext(), "Something went wrong!", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please fill all the fields!", Toast.LENGTH_SHORT).show(); } } } }); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { clearFields(); } }); } public void clearFields() { accountNumber.setText(""); initialBalance.setText(""); currentBalance.setText(""); interestRate.setText(""); paymentAmount.setText(""); cd.setChecked(false); loan.setChecked(false); checking.setChecked(false); } public void onRadioButtonClicked(View view) { boolean checked = ((RadioButton) view).isChecked(); switch (view.getId()) { case R.id.cd: if (checked) { accountNumber.setEnabled(true); initialBalance.setEnabled(true); currentBalance.setEnabled(true); interestRate.setEnabled(true); paymentAmount.setEnabled(false); } break; case R.id.loan: if (checked) { accountNumber.setEnabled(true); initialBalance.setEnabled(true); currentBalance.setEnabled(true); interestRate.setEnabled(true); paymentAmount.setEnabled(true); } break; case R.id.checking: if (checked) { accountNumber.setEnabled(true); initialBalance.setEnabled(false); currentBalance.setEnabled(true); interestRate.setEnabled(false); paymentAmount.setEnabled(false); } break; } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!