Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package act;
- import java.util.Scanner;
- public class Challenge
- {
- public static void main(String[] args)
- {
- Scanner k = new Scanner(System.in);
- System.out.print("enter a nonzero positive number: ");
- int max = k.nextInt();
- int it = 0;
- int sum = 0;
- do {
- it ++;
- sum = sum + it;
- }while (it < max);
- System.out.println("the sum of the numbers between 1 and "+max+" is "+sum);
- k.close();
- }
- }
Add Comment
Please, Sign In to add comment