int total=0; int n; import static javax.swing.JOptionPane.*; String input; input = showInputDialog("Please enter a value for n, an integer: "); n=int(input); //n = 6; for ( int i = 1; i<=n; i=i+1){ total = total + i; } println("The sum of the first",n,"natural numbers is",total);