I'm learning Java from a MOOC and am stuck on this one exercise:
Really having trouble with this one. I'm able to create a program that counts up to the user's chosen number (below) but stuck on how to add all the numbers up to variable n.
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int start = 0;
System.out.println("Until which number? ");
int n = Integer.parseInt(reader.nextLine());
System.out.println("Counting begins now...");
while (start <= (n - 1)) {
System.out.println(start += 1);
}
}
Any help is appreciated.