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
Python programming:   (10pts) Write a function that calculates the tip for a meal.The user can choose...
Python programming:   (10pts) Write a function that calculates the tip for a meal.The user can choose the percentage of tip they wish to give. Show that it works by calculating an 18% tip for a meal that costs 45.89. (15pts) Write a program that computes and display the charges for a patients hospital stay. The program should ask if the person is an in-patient or an out-patient. If the patient is an in-patient, ask the user to enter the number...
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...
Java Programming COMP-228 LAB ASSIGNMENT #1 >> Apply the naming conventions for variables, methods, classes, and...
Java Programming COMP-228 LAB ASSIGNMENT #1 >> Apply the naming conventions for variables, methods, classes, and packages: - variable names start with a lowercase character for the first word and uppercase for every other word - classes start with an uppercase character of every word - packages use only lowercase characters - methods start with a lowercase character for the first word and uppercase for every other word Java Programming COMP-228 Exercise #1: [5 marks] Write a Java application using...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT