Im trying to write a program that asks the user for a positive nonzero integer value. The program should use a loop to get the sum of all the integers from 1 up to the number entered. For example, if the user entered a 50, the loop will find the sum of 1,2,3,4,....50.
i think the code i posted may be wrong but ive spent hours trying to figure it out and my teacher isnt helpful at all. :(
i really would appreciate it if a full solution code is posted. This will help me study for my other programs im having trouble with.
public class SumOfNumbers
public static void main( String  args)
for( int count = 1; count <= nonZero; count++ )
input = JOptionPane.showInputDialog(null, "Please enter a nonzero positive integer.");
nonZero = Double.parseDouble(input);
JOptionPane.showMessageDialog(null, "The sum of the integers is: " + nonZero);