forked from MiYazJE/Acepta-el-reto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p140.java
41 lines (26 loc) · 869 Bytes
/
p140.java
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
31
32
33
34
35
36
37
38
39
40
41
import java.util.Scanner;
public class reto{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String total;
int suma;
int digito;
do {
total = sc.nextLine();
suma = 0;
if(("" + total.charAt(0)).equals("-")){
break;
}
for(int i=0; i<total.length(); i++){
digito = Integer.parseInt("" + total.charAt(i));
suma += digito;
if(i == total.length()-1){
System.out.print(digito + " = " + suma);
} else {
System.out.print(digito + " + ");
}
}
System.out.println();
} while(0 <= Integer.parseInt(total));
}
}