You don’t store the input numbers, if you only want to print them in the end it is sufficient to store them in a string numbers += " " + Integer.toString(number);
.
The whole main would then look something like that:
public static void main(String[] args) {
int mstop;
int number;
int sum;
int mcounter;
String numbers = "";
Scanner input = new Scanner(System.in);
System.out.print(" Now many numbers am I adding? ");
mstop = console.nextInt();
System.out.println();
sum = 0;
mcounter = 0;
System.out.println(" Please provide " + mstop + " numbers.");
while (mcounter < mstop) {
number = console.nextInt();
sum = sum + number;
numbers += " " + Integer.toString(number);
mcounter++;
}
System.out.print("The sum of these " + mstop + " numbers:" + numbers
+ " = " + sum);
System.out.println();
if (mcounter != 0) {
System.out.printf("Thank you for your input");
}
}
2
solved can someone please point me in the right direction