Question

android programming Bill amount ----------------- Percent ------------------(using seek bar) Tip Total (Bill amount + percent) Split...

android programming

Bill amount -----------------

Percent ------------------(using seek bar)

Tip

Total (Bill amount + percent)

Split bill (use Spinner)(no way, one way , two way, three way)

per person ---(use if and else to give manual amount per person)

Homework Answers

Answer #1

you initialised apply button as seekbar,this is the only mistake you did.after correcting the statements the activity calss is as follows

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.SeekBar;
import android.widget.TextView;

public class TipCalculatorActivity extends AppCompatActivity {

private EditText et_bill_amount;
private TextView tv_tip,tv_total,tv_percent;
private SeekBar seekBar;
private Button applyButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Initialize edittext, seekbar, textViews and apply button.
et_bill_amount=(EditText)findViewById(R.id.billAmountEditText);
tv_total=(TextView)findViewById(R.id.totalTextView);
tv_tip=(TextView)findViewById(R.id.tipTextView);
tv_percent=(TextView)findViewById(R.id.percentTextView);
seekBar=(SeekBar)findViewById(R.id.percentSeekBar);
applyButton=(Button)findViewById(R.id.applyButton);

applyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
calculateAndDisplay();
}


});
}

private void calculateAndDisplay() {
//Get seekbar progress value
int percent=seekBar.getProgress();

//Set percent value to percentTextView
tv_percent.setText(String.valueOf(percent)+"%");

//Extract entered bill amount and store in billAmount.
float billAmount=Float.valueOf(et_bill_amount.getText().toString());

//Calculate tip and total.
float tip=billAmount*((float)percent/100);
float total=billAmount+tip;

//Set tip and total values respectively
tv_tip.setText("$"+String.valueOf(tip));
tv_total.setText("$"+String.valueOf(total));
}
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. Write one problem using a dollar amount of $420 and a percent of 40%. provide...
1. Write one problem using a dollar amount of $420 and a percent of 40%. provide the solution to your problem 2. The sale price of an item is $ after % discount. What was the original price of the item? 3. Jane paid $40 for an item after she received a 20% discount. Jane's friend says this means that the original price of the item was $48. How did Jane's friend arrive at this moment? Is her friend correct?...
Problem #1 Confidence Interval for Means using the t and z Distribution.    Psychologists studied the percent...
Problem #1 Confidence Interval for Means using the t and z Distribution.    Psychologists studied the percent tip at a restaurant when a message indicating that the next day’s weather would be nice was written on the bill. Here are tips from a random sample of patrons who received such a bill, measured in percent of the total bill: 20.8     18.7     19.9     20.6     21.9     23.4     22.8     24.9     22.2     20.3   24.9     22.3     27.0     20.4     22.2     24.0     21.1     22.1     22.0     22.7 Open an...
(4 pts) Fill in the contingency table below using the following information: 800 patients are entered...
(4 pts) Fill in the contingency table below using the following information: 800 patients are entered into a trial of a new serum to cure Ebola. The patients are split equally into two groups, one of which is given the serum and one of which is not. Of the group given the serum, eighty percent recover, while only fifty-five percent of those not given the serum recover. Use this information to calculate the numbers to fill in the table. Make...
Identify the correct statement: A. Managers naturally seek to maximize shareholders' wealth B. Managers act in...
Identify the correct statement: A. Managers naturally seek to maximize shareholders' wealth B. Managers act in their own interests, and so there is no way to align their interests with those of the owners C. To motivate managers in non-profit firms, no employee incentives are needed D. To align the interests of managers and owners, owners must design systems to monitor and reward management behavior that increases the firm's profits Internal control systems: A. are the responsibility of the external...
In Haiti, public transportation is often by taptaps, small pickup trucks with seats along the sides...
In Haiti, public transportation is often by taptaps, small pickup trucks with seats along the sides of the pickup bed and railings to which passengers can hang on. Typically they carry two dozen or more passengers plus an assortment of chickens, goats, luggage, etc. Putting this much into the back of a pickup truck puts quite a large load on the truck springs. A truck has springs for each wheel, but for simplicity assume that the individual springs can be...
Please do not attempt to solve if you can not answer all!!! THE ENERGY BAR INDUSTRY...
Please do not attempt to solve if you can not answer all!!! THE ENERGY BAR INDUSTRY In 1986, PowerBar, a firm in Berkeley, California, single-handedly created the energy bar category. Positioned as an athletic energy food, it was distributed at bike shops and events that usually involved running or biking. The target segment was the athlete who needed an efficient, effective energy source. Six years later, seeking to provide an alternative to the sticky, dry nature of the PowerBar, a...
Sunshine Enterprises Case Study “I think the waiter wrote in an extra $25 tip on my...
Sunshine Enterprises Case Study “I think the waiter wrote in an extra $25 tip on my Sunshine Café bill after I received and signed my credit card receipt,” Mr. Mark Otter said to the restaurant manager, Brad Gladiolus. “Mr. Otter, mail me a copy of the restaurant receipt and I’ll investigate,” responded Mr. Gladiolus. “I don’t have the receipt—I lost it—but I have my monthly credit card statement,” replied Mr. Otter. Mr. Gladiolus hesitated, then said, “Mr. Otter, I don’t...
United Bankshores, Inc. wishes to evaluate three capital investment proposals by using the net present value...
United Bankshores, Inc. wishes to evaluate three capital investment proposals by using the net present value method. Relevant data related to the proposals are summarized as follows: Branch Office Expansion Computer System Upgrade Install Internet Bill-Pay Amount to be invested $532,596 $353,235 $210,792 Annual net cash flows: Year 1 311,000 208,000 146,000 Year 2 289,000 187,000 101,000 Year 3 264,000 166,000 73,000 Present Value of $1 at Compound Interest Year 6% 10% 12% 15% 20% 1 0.943 0.909 0.893 0.870...
United Bankshores, Inc. wishes to evaluate three capital investment proposals by using the net present value...
United Bankshores, Inc. wishes to evaluate three capital investment proposals by using the net present value method. Relevant data related to the proposals are summarized as follows: Branch Office Expansion Computer System Upgrade Install Internet Bill-Pay Amount to be invested $1,111,121 $656,453 $354,891 Annual net cash flows: Year 1 425,000 315,000 183,000 Year 2 395,000 284,000 126,000 Year 3 361,000 252,000 92,000 Present Value of $1 at Compound Interest Year 6% 10% 12% 15% 20% 1 0.943 0.909 0.893 0.870...
***Programming language is Java. After looking at this scenario please look over the requirements at the...
***Programming language is Java. After looking at this scenario please look over the requirements at the bottom (in bold) THIS IS ALL THAT WAS PROVIDED. PLEASE SPECIFY ANY QUESTIONS IF THIS IS NOT CLEAR (don't just say more info, be specific)*** GMU in partnership with a local sports camp is offering a swimming camp for ages 10-18. GMU plans to make it a regular event, possibly once a quarter. You have been tasked to create an object-oriented solution to register,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT