- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddNNumbers.java
More file actions
Latest commit
23 lines (16 loc) · 504 Bytes
/
Copy pathAddNNumbers.java
File metadata and controls
23 lines (16 loc) · 504 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
importjava.util.Scanner;
publicclassAddNNumbers {
publicstaticvoidmain(String[] args) {
Scannersc = newScanner(System.in);
System.out.print("How many Number You want to Enter to Add them ? ");
intn = sc.nextInt();
System.out.print("Enter " +n+ " numbers : ");
intsum = 0;
for(inti =0; i < n; i++ ){
// int sum = 0;
intnum = sc.nextInt();
sum = sum + num;
}
System.out.print("Sum of all " +n+ " numbers is " +sum);
}
}