I am writing a program that asks the user to input a positive integer and to calculate the sum from 1 to that number. Need some tips on what i'm doing wrong.
Here is the code:
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter a positive integer");
int getNumber=keyboard.nextInt();
int x;
int total = 0;
for (x=1;x<=getNumber;x++) {
total=x+1;
}
System.out.println(total);
}