For example, if i was to define with my user input that the array had a length of 4, I could then ask for the values of the array (eg, a random assortment could be 1,7,5,3,2) and then print them out as 1 7 5 3 2 instead of 0 0 0 0 0 as I keep getting...
Any help or advice would be greatly appreciated.
import java.util.*;
public class sequencer {
public int amount;
public int tally;
public int counter;
Scanner reader = new Scanner (System.in);
public void sorter () {
int[] numbers;
tally = 0;
System.out.print("How many integers are in this sequence?");
amount = reader.nextInt();
numbers = new int [amount];
counter = amount;
while (amount < 0){
System.out.println("dont be silly!");
amount = reader.nextInt();
}
while (tally < counter){
for (int i=1; i<= amount; i++){
System.out.print("Please enter value "+tally+":");
inters=reader.nextInt();
tally ++;
}
}
if (tally >= counter) {
System.out.println("Results: ");
int x;
for (x = 0; x < inters; ++x){
System.out.print (" " + numbers [amount]);
}
}
}
}

New Topic/Question
Reply



MultiQuote







|