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

  • Home
  • SEARCH
  • 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 7008019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:40:54+00:00 2026-05-27T21:40:54+00:00

My application shut down unexpectedly, I don’t really know what the problem is. I’m

  • 0

My application shut down unexpectedly, I don’t really know what the problem is. I’m new to programming java. I tried the ‘try’, ‘catch’ and ‘finally’ methods.
Here is the code:

package com.eqsec.csaba;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class EqsecActivity extends Activity {
/** Called when the activity is first created. */

Button solve;
EditText vA, vB, vC;
TextView solution;
int discriminant, iA, iB, iC;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    solve = (Button) findViewById(R.id.bSolve);
    vA = (EditText) findViewById(R.id.etA);
    vB = (EditText) findViewById(R.id.etB);
    vC = (EditText) findViewById(R.id.etC);

    solve.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                try{
                String A = vA.getText().toString();
                iA = Integer.parseInt(A);
               String B = vB.getText().toString();
                iB = Integer.parseInt(B);
                String C = vC.getText().toString();
                iC = Integer.parseInt(C);


            solution.setText("Yout total is " + iA);
                }catch (ArithmeticException e) {
                    e.printStackTrace();
                }


            }
        });


              }
       }

Please help me, i want to write an android application, which can solve some math problems.

  • 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-05-27T21:40:55+00:00Added an answer on May 27, 2026 at 9:40 pm

    You have to catch NumberFormatException instead of ArithmeticException.

    And initialize solution variable before. Like:

    solution = (TextView) findViewById(R.id.solution);
    

    Full code will be:

    package com.eqsec.csaba;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    
    public class EqsecActivity extends Activity {
    /** Called when the activity is first created. */
    
    Button solve;
    EditText vA, vB, vC;
    TextView solution;
    int discriminant, iA, iB, iC;
    
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    solve = (Button) findViewById(R.id.bSolve);
    vA = (EditText) findViewById(R.id.etA);
    vB = (EditText) findViewById(R.id.etB);
    vC = (EditText) findViewById(R.id.etC);
    solution = (TextView) findViewById(R.id.solution);
    
    solve.setOnClickListener(new View.OnClickListener() {
    
            public void onClick(View v) {
                // TODO Auto-generated method stub
                try{
                String A = vA.getText().toString();
                iA = Integer.parseInt(A);
               String B = vB.getText().toString();
                iB = Integer.parseInt(B);
                String C = vC.getText().toString();
                iC = Integer.parseInt(C);
    
    
            solution.setText("Yout total is " + iA);
                }catch (NumberFormatException e) {
                    e.printStackTrace();
                }
    
    
            }
        });
    
    
              }
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to force my application to shut down, and return an Exit code.
Is there a way to open/close (i.e. start-up/shut-down) a winform application via ASP.NET? I'm
I have a fun issue where during application shutdown, try / catch blocks are
I want to save some integers after application shut down and restore them after
I want to prevent users from shut down or restart the system. my application
Not long after upgrading to VS2010, my application won't shut down cleanly. If I
Not long after upgrading to VS2010, my application won't shut down cleanly. If I
My application is shut down somehow only in release mode. And I can't even
I'm trying to write an application to shut down my pc when I shutdown
I want my C# program to shut down a certain legacy application before proceeding.

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.