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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:56:24+00:00 2026-05-27T16:56:24+00:00

If anyone can help me I would be grateful! It should be converted the

  • 0

If anyone can help me I would be grateful! It should be converted the three EditText variables into strings and then integers. I added the exception because without it, the program crashed on startup. I’m not sure whether the problem is in the conversion of the variables, in my try catch code, or in both. Please help!

package boston.project;

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 TheBostonProjectActivity extends Activity {

public EditText aed, bed, ced;
public TextView dtv;
public int a, b, c;
public Button solve;
public double dis;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


        aed = (EditText)(findViewById(R.id.etA));
                    try {
                        a = Integer.parseInt(aed.getText().toString());
                        } catch (NumberFormatException e) {
                            a = 0;
                        }
        bed = (EditText)(findViewById(R.id.etB));
                    try {
                        b = Integer.parseInt(bed.getText().toString());
                        } catch (NumberFormatException e) {
                            b = 0;
                        }
        ced = (EditText)(findViewById(R.id.etC));
                    try {
                        c = Integer.parseInt(ced.getText().toString());
                        } catch (NumberFormatException e) {
                            c = 0;
                        }

    solve = (Button)(findViewById(R.id.bsolve));

    solve.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click
            dis = (b*b)-(4*a*c);
            dtv = (TextView)findViewById(R.id.tvdis);
            dtv.setText("Discriminant:" + dis);
        }
    });

}
}
  • 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-27T16:56:24+00:00Added an answer on May 27, 2026 at 4:56 pm

    You are trying to get the text from EditTexts just after you created them (by calling setContentView). They are all empty – contain no text. And since

    Integer.parseInt("");
    

    Throws an exception, all your catch blocks are executed (and that means, that they actually work, not the contrary).

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

Sidebar

Related Questions

I'm not skilled with javascript so if anyone can help me I would be
I was wondering if anyone can help me get started with creating a room
Wondering if anyone can help me with this annoying but trivial (in terms of
Wonder if anyone can help me understand how to sum up the column of
I wonder if anyone can help improve my understanding of JOINs in SQL. [If
I wonder if anyone can help - I have this error showing recently when
I wonder if anyone can help me to understand where I could be going
I am new in Symbian UIQ. So anyone can help me out about following
I'm new to querying XML datatype in SQL Server 2005. Anyone can help me
Anyone that can help me out will be very much appreciated. I seem to

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.