-4

I am wanting to building an ArrayList, that later will be used to display information to a table.

The Issue is, I want my array to contain information that is in increments of 5000, up to 150+% the initial value.

IE:

User enters 100000.

The information in the array would look as such.

100002
105002
110002
115002
120002
125002
.
.
.
.
150002
155002

No code yet other than collect user input, just looking for a place to start with this.

Matthew Kelsay
  • 95
  • 1
  • 3
  • 10

2 Answers2

0
int input = 100000;//user input
ArrayList<Integer> nums = new ArrayList<Integer>();
for(int i = 0; i <= (input/2); i+=5000){
     nums.add(input+i);
 }

This loop will get you started, if you'd like to have multiple columns, then you can use a 2D array instead. If you have further questions about 2D arrays, I would look here.

Community
  • 1
  • 1
Arman
  • 655
  • 2
  • 7
  • 23
  • If I input 100002 result will not be +50% – Grim May 21 '16 at 18:18
  • 1
    Why do `double` math? `max / 2` would suffice. Why the extra parenthesis in `add((max+i))`? Just do `add(max+i)`. And the input isn't really "max", but rather "input", "start", or "min" if anything. – Andreas May 21 '16 at 18:25
0
double num = sales * 1.5 + 5000;
ArrayList<Double> salesArList = new ArrayList<Double>();
double i = sales;
do{
    salesArList.add(i);
    i = i + 5000;
}while(i <= num);
Laurel
  • 5,965
  • 14
  • 31
  • 57
Matthew Kelsay
  • 95
  • 1
  • 3
  • 10