File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Calculation Change in numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calculation Change in numbers" Watch "Calculation Change in numbers" New topic
Author

Calculation Change in numbers

Matt Deg
Greenhorn

Joined: Mar 02, 2012
Posts: 7
I need to calculate the change in certain values of numbers I have put asterisks around where I need help with the numbers I am using are
1112365 5567821 1234677
3000765 7563460 954680
4012765 12123225 883452
5674780 17192360 755242
10680140 26075960 663459

So in the specified area I need the program to calculate change going down the column, I don't need the changes to be listed I only need the average change in the end....right now I know the code for that part is nowhere near right...any help would be much appreciated...



Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18121
    
    8

(I added the Code tags around your code so it would be readable...)

Well, I can't quite tell what your code is supposed to be doing; probably if I read the instructions carefully I could figure it out, but let's start with what you did:



If I'm not mistaken, what you have in the brackets at the right-hand end involves subtracting a number from itself. And that always produces zero. So whatever you were trying to do with that code, that isn't right.
Matt Deg
Greenhorn

Joined: Mar 02, 2012
Posts: 7
Thank you and what I need to be doing there is i believe calculate the total change in numbers between the 5 numbers...so for the first group the average change between the number 1112365, 3000765, 4012765, 5674780, 10680140....essentially what the idea is we are to calculate the average change in the members that use a particular site, the numbers represent the users in 5 different years....this is similar to what i need it to produce
The program would produce output similar to: The asterisked line is what i need the specified section of my code to produce but with the numbers i provided instead of the numbers below...let me know if any further clarification is need, I will try to explain it better

Welcome to Growth Statistics ...
a program to calculate the growth in a
social media Web site over five years.

13-24 25-54 55+
----- ----- -----
2005: 100 100 100
2006: 200 100 100
2007: 300 100 100
2008: 400 200 100
2009: 500 300 100
----- ----- -----

Avg change: 100 60 20 *********************


Programming exiting.

Note: for category 13-24 the average is (100+100+100+100+100)/5 == 100;
for category 25-54 the average is (100+0+0+100+100)/5 == 60;
and for category 55+ the average is (100+0+0+0+0)/5 == 20;
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18121
    
    8

Matt Deg wrote:what I need to be doing there is i believe calculate the total change in numbers between the 5 numbers...so for the first group the average change between the number 1112365, 3000765, 4012765, 5674780, 10680140....


Okay. So Java and computers aside, if you only had a pencil and paper, how would you do that calculation for the five numbers you showed there?
Matt Deg
Greenhorn

Joined: Mar 02, 2012
Posts: 7
Change = x2-x1 , but I'm not sure how to make that work with my loop, from my very limited understanding of what I am doing I can only work as the loop is running is the previous change and the new number, I don't know how or if I can use the number from the previous loop
Matt Deg
Greenhorn

Joined: Mar 02, 2012
Posts: 7
Never mind I think I have it, sorry not very good at this stuff, although I may need help printing the table at the end of the program
Matt Deg
Greenhorn

Joined: Mar 02, 2012
Posts: 7
This is the code as far as I have gotten it, now I need to make a nice neat table, for which I can't get my values to print from my array, or the years to print out vertically, it should look like this...more or less I really just want some form of it to print...again asterisks around the problem area...Thank you
13-24 25-54 55+
----- ----- -----
2005: 100 100 100
2006: 200 100 100
2007: 300 100 100
2008: 400 200 100
2009: 500 300 100
----- ----- -----

Avg change: 100 60 20


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calculation Change in numbers
 
Similar Threads
I think I'm stuck!!
Help setting up an array and other issues
trouble using .useDelimiter
Getting the average to display
Multiplication table from a file