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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:55:37+00:00 2026-06-06T04:55:37+00:00

I have a 10-field average lap calculator. However, in testing, someone said they normally

  • 0

I have a 10-field average lap calculator. However, in testing, someone said they normally only run X laps in practice, vs. 10 (let’s say 7).

I think I could use an if statement, but there’d be at least 10 of them and a bunch of clumsy code, and I’m not sure on arrays/switch statements exactly. I think all of those might be possible, but my low level of experience has yet to fully comprehend these useful tools.

CURRENT CODE:

double tenLapAvgVar = ((lap1Var + lap2Var + lap3Var + lap4Var + lap5Var + lap6Var + lap7Var + lap8Var + lap9Var + lap10Var) / 10);

So essentially, if someone leaves a field or fields blank, I want to calculate the average based on the populated fields, not 10 (if they leave 3 fields blank, calculate based on 7, for instance). Any help you guys could provide would be much appreciated, thanks!

  • 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-06T04:55:41+00:00Added an answer on June 6, 2026 at 4:55 am

    You could have an ArrayList<EditText> object and a method which iterates over it and adds up the values. Something like:

        public double getLapAverage()
        {
        int noOfCompletedLaps = 0;
    
        double lapAve = 0;
        double lapsTotal = 0;    
    
        for(EditText text : textBoxes)
        {
           if(text.getText().toString().length() > 0)
           {
              //psuedo code, and assuming text is numerical
              lapsTotal += Double.parse(text.getText().toString());
              noOfCompletedLaps++;
           }
        }
    
        if( noOfCompletedLaps > 0)
        {
           lapAve = lapsTotal / noOfCompletedLaps;
        }
    
     return lapAve;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some javascript I want to run when a hidden field is changed
I have a text field that can be 30 characters in length, however it
I have field like a_b_c_d I want as the output a b c_d, this
I have field X that contains text with spaces in the end of the
in my jqgrid i have field in a table which represents the id and
I my index lets say I have field field named full_name. I'm doing following
In my class, I have field int count . I want to create a
I have a field type varchar in sql server. It contains data like 010109
I have a field in a table which contains bitwise flags. Let's say for
I have a field in a CCK node form that is hidden, and has

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.