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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:22:02+00:00 2026-06-02T20:22:02+00:00

I’m wanting to find the average difference of the array totals. My array structures

  • 0

I’m wanting to find the average difference of the array totals.

My array structures are as follows (pulled from a database):

day, 1, 2, 3, 4

So you can see the 5 arrays how it’s pulled from the database.

Now for instance, the Java algorithm I need is as follows:

To add each of the 1,2,3,4 values up, then loop to the next day (if there is one), repeating the same addition. Then eventually, calculate the ‘average difference’ between the totals of each day.

So for example, i’ve done some sample data to try and make it clearer for you!

1 (Mon)     135 90  105 150
2 (Tues)    143 86  117 163
3 (Wed)     129 100 140 158

So what the algorithm needs to do is:

135+90+105+150 = 500,

143+86+117+163 = 509,

129+100+140+158 = 527

But the only problem, is that, column 1 is its own array and column 2,3,4 preceding.

Calculate the ‘average increase/decrease’ which would be:

https://math.stackexchange.com/questions/16554/what-is-average-increase-percentage-and-how-to-calculate-it

I’m unsure how to implement it into Java! Any help would be appreciated.

If i can provide any more information please let me know.

Many 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-02T20:22:05+00:00Added an answer on June 2, 2026 at 8:22 pm

    Since we know the location of the items in the database, the following might work:

    /*Psudeocode:
    ArrayList<Integer> firstCol = //get first column
    ArrayList<Integer> secondCol = //get second column
    ....
    ArrayList<Integer> nCol = //get n column
    */
    ArrayList<Integer> values = new ArrayList<Integer>();
    int currentRow;
    for(int i=0;i<n;i++)
    {
         currentRow = 0;
         currentRow += firstCol.get(i);
         currentRow += secondCol.get(i);
         //etc, etc...
         values.add(currentRow);
    }
    //At this point, values contains all the sums of the different rows.
    //To calculate the average percent change:
    //PR= (((Vpresent - Vpast) / Vpast) x 100) / N
    for(int i=0;i<values.size() -1;i++)
    {
        System.out.println(((values.get(i+1) - values.get(i)) * 100) / (i+1))
    }
    

    I hope this helps. Help with Average Percent Change

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

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

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.