0
sum of output
Hey How can we sum numbers in the output of code below. Thanks import java.util.Scanner; public class IDCode{ public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Enter ID Code:"); int x = input.nextInt(); String s = Integer.toString(x); System.out.println(s.length()==10?true:false); int b = 0; int c = 10; int sum = 0; for(int i = 0; i < s.length();i++){ b = Integer.parseInt(""+s.charAt(i))*c; System.out.println(b); --c; } } }
1 Respuesta
+ 2
sum += b;
At the end of the loop.