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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:56:39+00:00 2026-06-03T20:56:39+00:00

This function returns a 0.0 althought all the values are float and are retrieved

  • 0

This function returns a 0.0 althought all the values are float and are retrieved correctly from the shared preferences ! what could be the error?

float BMR(){

    SharedPreferences customSharedPreference = getSharedPreferences(
                "myCustomSharedPrefs", Activity.MODE_PRIVATE);

    String  Weight =customSharedPreference.getString("weightpref", null);
    float weight = Float.valueOf(Weight);

    String  Height = customSharedPreference.getString("heightpref",null);
    float height = Float.valueOf(Height);
    String Age = customSharedPreference.getString("agepref", null);
    float age = Float.valueOf(Age);

    int gender = customSharedPreference.getInt("genderpref", 0);

    Toast.makeText(StatsActivity.this, Age, Toast.LENGTH_LONG).show();
    if ( gender == 0){
        bmr = (float) (10.0 *weight + 6.25 * height - 5.0 * age + 5.0);
    }
    if(gender == 1){
        bmr = (float) (10.0 * weight + 6.25 * height - 5.0 * age- 161.0);
    }

    String bmrtest = String.valueOf(bmr);
    Toast.makeText(StatsActivity.this, "bmr is "+bmrtest, Toast.LENGTH_LONG).show();
    return bmr;
    }
  • 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-03T20:56:40+00:00Added an answer on June 3, 2026 at 8:56 pm

    What happens if gender is not 0 or 1? Your bmr would remain unassigned (to 0.0).

    If that’s the problem, you may consider, for the future, to:

    • put an else clause after your if’s
    • group those two ifs into an elseif (since they are exclusive)
    • at the very least put in an assert to check that gender is indeed 1 or 0
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function which returns a datatype InetAddress[] public InetAddress [] lookupAllHostAddr(String host)
document.onkeydown.toString() returns onkeydown function but I only want to get this function's name. Is
I intended for this function to call my MVC action method that returns a
Let's say that some function returns object reference. How one should properly spell: this
How is this possible that the str_replace() function below returns biWeekly and not Every
This has me stumped. The follow code returns ,,,,,,: <script type=text/javascript> $(function() { $('#listB').sortable({
I've a function GetPassword , that returns a SecureString type. When I pass this
I got a function like def f(): ... ... return [list1, list2] this returns
I'm using this function from here , which is: // highlight search keywords function
i have this function to return the full directory tree : function getDirectory( $path

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.