-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddLoop.java
More file actions
30 lines (26 loc) · 811 Bytes
/
addLoop.java
File metadata and controls
30 lines (26 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Created by fattyduck on 3/23/15.
*/
import java.util.Scanner;
public class addLoop {
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int total, times, input, addition, x;
System.out.println("I will add up x amount of numbers for you");
System.out.println("So how many numbers are you planning to add up?");
x=scan.nextInt();
times=0;
total=0;
if(x>0){
while(x!=times){
System.out.println("Number: ");
input=scan.nextInt();
total+=input;
System.out.println("Total is "+total);
times++;
}
}else{
System.out.println("So you don't need to add anything together");
}
}
}