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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:51:36+00:00 2026-06-15T09:51:36+00:00

The issue i’m having is that when I enter no data at all or

  • 0

The issue i’m having is that when I enter no data at all or if there is only data in one of the input boxes the program crashes but if there is any data in both boxes the program works fine so how do I stop it from sending data if nothing is entered. The error says it can parse a double of value “”

    calculate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            distanceTraveled = Double.parseDouble(distance.getText().toString());
            fuelUsed = Double.parseDouble(fuel.getText().toString());
            part1 = fuelUsed / 4.55;
            mpg = distanceTraveled / part1;
            total.setText(String.format("%.2f", mpg));
        }
    });
  • 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-15T09:51:37+00:00Added an answer on June 15, 2026 at 9:51 am

    Chnage EditView for empty or null before making calculation :

    alculate.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
              if(distance.getText().toString().length() > 0){
    
                distanceTraveled = Double.parseDouble(distance.getText().toString());
            }
            else{
                  distanceTraveled=0; // put default value here
              }
            if(fuel.getText().toString().length() > 0){  
                   fuelUsed = Double.parseDouble(fuel.getText().toString());
              }
              else{
                   fuelUsed=0;// put default value here
    
               }
                part1 = fuelUsed / 4.55;
                mpg = distanceTraveled / part1;
                total.setText(String.format("%.2f", mpg));
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Issue I get for one of my shared data sets only on certain parameters.
Issue I'm having is returning some data in a sidebar depending on which category
Main issue is that I'm developing an app for Android and iOS but can't
Issue is that I have one value that is returned by $(this).attr(ows_Modified); //(Sharepoint and
My issue is that I'm trying to mock BluetoothDevice for some testing, but it's
Issue is only with Safari: I have three tabs that each show a div
Issue for text elements that are adjacent to icon elements, the glyph height is
// issue with the following not returning info or just stalling... but no errors
Issue - We have a spreadsheet with thousands of addresses but no counties. Goal
Issue is SOLVED: Problem is that it is a pre-compiled web page project and

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.