Main.java 538B

1234567891011121314151617181920212223242526
  1. /**
  2. * Created by iyasuwatts on 10/17/17.
  3. */import java.util.Scanner;
  4. public class Main {
  5. public static void main(String[] args){
  6. Scanner number = new Scanner(System.in);
  7. System.out.println("Please enter a Number:");
  8. //user input
  9. int n = number.nextInt();
  10. //
  11. int sum= 0;
  12. // loop to add
  13. for(int i=0; i<=n; i++){
  14. sum=sum + i;}
  15. System.out.println("Sum of all numbers is" +" "+ sum);
  16. }
  17. }