Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Android Studio, develop a Tip Calculator App. The Tip Calculator app calculates and displays tips for a restaurant bill. As you enter a bill

Using Android Studio, develop a Tip Calculator App. The Tip Calculator app calculates and displays tips for a restaurant bill. As you enter a bill total, the app calculates and displays the tip amount and total bill for three common tipping percentages10%, 15% and 20%. The user can also specify a custom tip percentage by moving the thumb of a Seekbarthis updates the percentage shown to the right of the Seekbar. The suggested tips and bill totals are updated in response to each user interaction.

image text in transcribed

I managed to get the XML file set up but I am having trouble with the MainActivity.java file, mainly getting errors with my textViews and I am having trouble figuring out how to incorporate the Seekbar into my code. Help on this would be greatly appreciated!

XML:

                                           

MainActivity.java:

package com.example.rehmarazzakhmwk1; import android.os.Build; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Editable; import android.view.View; import android.widget.EditText; import android.widget.SeekBar; import android.widget.TextView; public class MainActivity extends AppCompatActivity { EditText totalBillAmount; TextView tenPercentTip, tenPercent; TextView fifteenPercentTip; TextView twentyPercentTip; TextView tenPercentTotal, fifteenPercentTotal, twentyPercentTotal; SeekBar seekBar; TextView progressTextView; TextView totalTip, totalAmount; Double money; double finalAmount; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ); setContentView( R.layout.activity_main ); totalBillAmount = (EditText) findViewById(R.id.totalBillAmount); tenPercentTip = (TextView) findViewById(R.id.tenPercentTip); tenPercent = (TextView) findViewById(R.id.tenPercent); fifteenPercentTip = (TextView) findViewById(R.id.fifteenPercentTip); fifteenPercent = (TextView) findViewById(R.id.fifteenPercent); twentyPercentTip = (TextView) findViewById(R.id.twentyPercentTip); twentyPercent = (TextView) findViewById(R.id.twentyPercent); tenPercentTotal = (TextView) findViewById(R.id.tenPercentTotal); fifteenPercentTotal = (TextView) findViewById(R.id.fifteenPercentTotal); twentyPercentTotal = (TextView) findViewById(R.id.twentyPercentTotal); seekBar = (SeekBar) findViewById(R.id.seekBar); progressTextView = (TextView) findViewById(R.id.progressTextView); totalTip = (TextView) findViewById(R.id.totalTip); totalAmount = (TextView) findViewById(R.id.totalAmount); } @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1) public void onclick(View view) { if(totalBillAmount.getText().toString() == "") { tenPercentTip.setText("0.00"); } else { finalAmount = 0.00; finalAmount = money*.01; //tenPercentTip.setText(totalBillAmount.getText().toString()); } if (view.getId() == tenPercent.getId()) { finalAmount = money * .10; finalAmount = Math.round(finalAmount *100.0) / 100.0; textView.setText("$" + finalAmount.toString()); } if (view.getId() ==fifteenPercent.getId()){ finalAmount = money * .15; finalAmount = Math.round(finalAmount *100.0) / 100.0; textView.setText("$" +finalAmount.toString()); } if (view.getId() == twentyPercent.getId()){ finalAmount = money * .2; finalAmount = Math.round(finalAmount *100.0) / 100.0; textView.setText("$" + finalAmount.toString()); } } }
Requirements Develop an Android tip caleulator app. The layout is shown as f Rows and columns in a TableLayout column 0 column column 2 column 3 row 0 Bill total 0.00 row I row 2 10% Tip 0.00 row 3 Total 0.00 15% 20% 0.00 0.00 0.00 0.00 row 4 Custom 18% row 5 Tip 0.00 Total 0.00 Requirements Develop an Android tip caleulator app. The layout is shown as f Rows and columns in a TableLayout column 0 column column 2 column 3 row 0 Bill total 0.00 row I row 2 10% Tip 0.00 row 3 Total 0.00 15% 20% 0.00 0.00 0.00 0.00 row 4 Custom 18% row 5 Tip 0.00 Total 0.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions