Can someone explain why, when I input values, the output is increased by 9, for all the values stored in the array?
int [] number;
int numCounter,num;
userInt validate = new userInt();
//set the number of array it can hold
number = new int[100];
//set the counter to be equal to zero;
numCounter = 0;
validate.InputString("enter up to 100 positive integer;");
while(true){
validate.InputString("enter 0 to end");
num = validate.userInt();
//this will exist the loop statement
if(num <= 0)
break;
number[numCounter] = num;
numCounter++;
}
//this will print the enter number from the array in reversed order
for(int i = numCounter - 1; i >= 0; i--)
System.out.println(number[i] +'\t');
}
You are adding the int value of the tab character to each number, which is 9.
System.out.println(number[i] +'\t')
If you want to print a TAB after each number, change to :
System.out.println(number[i] + "\t");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With