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 8026935
In Process

The Archive Base Latest Questions

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

All- My project (calculating tips) worked fine until I added some BigDecimal variables to

  • 0

All-
My project (calculating tips) worked fine until I added some BigDecimal variables to help with rounding. Now, when I hit “Calculate” the application force closes and the logcat says:

 06-01 14:24:21.246: W/dalvikvm(15364): threadid=1: thread exiting with uncaught exception (group=0x40a4a1f8)
06-01 14:24:21.256: E/AndroidRuntime(15364): FATAL EXCEPTION: main
06-01 14:24:21.256: E/AndroidRuntime(15364): java.lang.IllegalStateException: Could not execute method of the activity
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.View$1.onClick(View.java:3044)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.View.performClick(View.java:3511)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.View.onKeyUp(View.java:6078)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.widget.TextView.onKeyUp(TextView.java:5636)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.KeyEvent.dispatch(KeyEvent.java:2623)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.View.dispatchKeyEvent(View.java:5500)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1879)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1361)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.app.Activity.dispatchKeyEvent(Activity.java:2324)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1806)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3327)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:3300)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2460)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.os.Looper.loop(Looper.java:137)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.app.ActivityThread.main(ActivityThread.java:4424)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at java.lang.reflect.Method.invokeNative(Native Method)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at java.lang.reflect.Method.invoke(Method.java:511)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at dalvik.system.NativeStart.main(Native Method)
06-01 14:24:21.256: E/AndroidRuntime(15364): Caused by: java.lang.reflect.InvocationTargetException
06-01 14:24:21.256: E/AndroidRuntime(15364):    at java.lang.reflect.Method.invokeNative(Native Method)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at java.lang.reflect.Method.invoke(Method.java:511)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at android.view.View$1.onClick(View.java:3039)
06-01 14:24:21.256: E/AndroidRuntime(15364):    ... 24 more
06-01 14:24:21.256: E/AndroidRuntime(15364): Caused by: java.lang.NumberFormatException: Invalid float: ""
06-01 14:24:21.256: E/AndroidRuntime(15364):    at java.lang.StringToReal.invalidReal(StringToReal.java:63)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at java.lang.StringToReal.parseFloat(StringToReal.java:289)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at java.lang.Float.parseFloat(Float.java:300)
06-01 14:24:21.256: E/AndroidRuntime(15364):    at com.tip.ping.TippingActivity.calculateNumbers(TippingActivity.java:47)
06-01 14:24:21.256: E/AndroidRuntime(15364):    ... 27 more

My code is:

 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) {
        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);


        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);


        EditText text3 = (EditText)findViewById(R.id.edit_people);
        String value3;
        value3 = text3.getText().toString();

        TextView answer = (TextView) findViewById(R.id.answer);
        String answers;
        answers = answer.getText().toString();
        float answerf = Float.parseFloat(answers);
        BigDecimal answerbd;
        answerbd = new BigDecimal(answerf);
        answerbd.setScale(2);   
        TextView quick_answer = (TextView) findViewById(R.id.quick_answer);
        String qanswers;
        qanswers = quick_answer.getText().toString();
        float qanswerf = Float.parseFloat(qanswers);
        BigDecimal qanswerbd;
        qanswerbd = new BigDecimal(qanswerf);       

        float l3 = Float.parseFloat(value3);
        BigDecimal l3bd;
        l3bd = new BigDecimal(l3);

        qanswerbd = billbd.multiply(tipbd).add(billbd);
        qanswerbd.setScale(2, RoundingMode.HALF_UP);
        String resultbd;
        resultbd = qanswerbd.toString();   

        quick_answer.setText(resultbd);     
    }
}

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:38:57+00:00Added an answer on June 4, 2026 at 11:38 pm

    Looks like an empty float value, but hard to say without line numbers ( Line 47 is…? )

    Caused by: java.lang.NumberFormatException: Invalid float: “”

    EditText text = (EditText)findViewById(R.id.edit_bill);
    String value = text.getText().toString();
    

    Does anything come back if you Log/Print value at this point?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've inherited a project where all the private variables, and there are thousands, are
hello all i really need your help its my final project in university i
Why running debug doesn't build all selected project in the active configuration? Normally I've
I have a project with all my Interface definitions: RivWorks.Interfaces I have a project
Eclipse is complaining about my Android project saying all my references to resources are
All of the web forms / pages that my project extend on a derived
All, We have a PHP project in SVN. We develop code and do SVN
In my A-Level project I have all the record info stored in an MS
I have a winform project which lists all the files in a specified folder.
In my current project I noticed that all class fields and variable inside methods

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.