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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:58:41+00:00 2026-06-01T06:58:41+00:00

As far as I know, I put in the correct try catch statements to

  • 0

As far as I know, I put in the correct try catch statements to stop the NumberFormatException…the NullPointerException may be coming from this:

TextView tvfin = null;
tvfin.setText(fin+"");
tvfin = (TextView)findViewById(R.id.tvfinalgrade);

Those three lines are going to be in an OnClickListener but I haven’t created it yet, I’m not sure if that could cause a problem?
Any help is much appreciated!

package wilson.GC;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

public class GFActivity extends Activity {

 @Override
    public void onCreate(Bundle savedInstanceState) {          

        super.onCreate(savedInstanceState);    
        setContentView(R.layout.getfinal);

        double q1, q2, ex, fin;
         EditText etq1, etq2, eteg;
         etq1 = (EditText)findViewById(R.id.editText1);
            try{
                q1 = Double.parseDouble(etq1.getText().toString());
            } catch (NumberFormatException e) {
                q1=0;
            }
         etq2 = (EditText)findViewById(R.id.editText2);
            try{
                q2 = Double.parseDouble(etq2.getText().toString());
            } catch (NumberFormatException e){
                q2 = 0;
            }
         eteg = (EditText)findViewById(R.id.editText3);
         try{
             ex = Double.parseDouble(eteg.getText().toString());
         } catch (NumberFormatException e){
             ex = 0;
         }
        fin = 0.4*q1+0.4*q2+0.2*ex;
            if(fin == (int)fin){
                System.out.println((int)fin);
            }
            else{
                fin = 0.01*((int)(fin*100));
                System.out.println(fin);
            } 
        TextView tvfin = null;
        tvfin.setText(fin+"");
        tvfin = (TextView)findViewById(R.id.tvfinalgrade);

    }
}
  • 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-01T06:58:42+00:00Added an answer on June 1, 2026 at 6:58 am

    Try setting tvfin before setting its text:

    TextView tvfin = (TextView)findViewById(R.id.tvfinalgrade);
    tvfin.setText(fin+"");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As far as I know, for a new request coming from a webapp, you
As far as I know there is no way to do this, but I
I don't know if this is even the correct terminology but I was wondering
As far as know, I must be careful with PHP, and I think Javascript.
As far as i know, there is no direct equivalent in C#. My current
As far as I know, only the convenience methods return created objects with an
so far i only know to use Ctrl-Shift-A to do SVN in TextMate. is
As far as I know, ASP.NET MVC leverages a lot of the features of
As far as I know document.getElementById('myId') will only look for HTML elements that are
As far as i know, the result of [a, A].uniq is [a, A] My

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.