1234567891011121314151617181920212223242526 |
- /**
- * Created by iyasuwatts on 10/17/17.
- */import java.util.Scanner;
- public class Main {
-
- public static void main(String[] args){
- Scanner number = new Scanner(System.in);
- System.out.println("Please enter a Number:");
- //user input
- int n = number.nextInt();
- //
- int sum= 0;
-
- // loop to add
- for(int i=0; i<=n; i++){
- sum=sum + i;}
- System.out.println("Sum of all numbers is" +" "+ sum);
-
-
-
-
-
-
- }
- }
|