Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8026241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:25:36+00:00 2026-06-04T23:25:36+00:00

All- I am having a hard time taking the value of an EditText and

  • 0

All-
I am having a hard time taking the value of an EditText and messing with it to preform equations and tasks like rounding and multiplying. I have heard that BigDecimal is a good way to do this but it was very difficult to get the variables to a type where they could become BigDecimal variables (View->String->Float->BigDecimal) and then to get them to a type where they could be outputted (BigDecimal->?).
Here is my code:

 public class TippingActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    public void calculateNumbers(View view) throws ParseException {
        // Bill
        EditText text = (EditText)findViewById(R.id.edit_bill);             
        String value;
        value = text.getText().toString();
        float bill = Float.parseFloat(value);       
        BigDecimal billbd;
        billbd = new BigDecimal(bill);


        //Tip
        EditText text2 = (EditText)findViewById(R.id.edit_tip);
        String value2;
        value2 = text2.getText().toString();    
        if(!value2.contains("."))
            value2 = "."+value2;
        float tip = Float.parseFloat(value2);
        BigDecimal tipbd;
        tipbd = new BigDecimal(tip);

        //People
        EditText text3 = (EditText)findViewById(R.id.edit_people);
        String value3;
        value3 = text3.getText().toString();
        float people = Float.parseFloat(value3);
        BigDecimal peoplebd;
        peoplebd = new BigDecimal(people);
        //Answer
        TextView answer = (TextView) findViewById(R.id.answer);
        //Answer to string
        String answerstring;
        answerstring = answer.getText().toString();
        //Answer to Float
        float answerfloat = Float.parseFloat(answerstring);
        //Answer to BigDecimal
        BigDecimal answerbig;
        answerbig = new BigDecimal(answerfloat);
        answerbig.setScale(2, RoundingMode.HALF_UP);
        answerbig = billbd.multiply(tipbd).add(billbd).divide(peoplebd);
        //Answer to String
        String answerfrombd = answerbig.getText().toString();        
        answer.setText(answerfrombd);       
    }
}

In the second line of code from the bottom I get an error on

`String answerfrombd = answerbig.getText().toString();`

because I can’t go from BigDecimal to String. Any ideas?
Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:25:39+00:00Added an answer on June 4, 2026 at 11:25 pm

    You can do, depending how you want it to display.

    answerbig.toPlainString() 
    

    or:

    answerbig.toBigInteger().toString()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm having a hard time getting this to work, all I need to do
I have 3 select boxes and all are having same value (clones) & created
I have one scenario where I need to select all files having aliencoders.numeric-digits like
I'm having a hard time figuring out why lseek doesn't work properly. Basically all
I'm having a hard time understanding how the CakePHP admin system works. Should all
I'm having a hard time dealing with stylesheets and javascripts. All the examples for
Having hard time installing GWT plugin. Tried to search for GWT plugins and all
I'm sure people do this all the time, but I'm having a hard time
Having a hard time with this one as I don't think I know all
I am having a hard time understanding JAAS. It all seems more complicated than

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.