//TestCode.java import java.util.Scanner; public class TestCode { public static void main(String[] args){ Scanner scnr = new Scanner(System.in); System.out.println("What is Sum?"); String a=""; a = scnr.nextLine(); int sum = 0; char ch; for(int i = 0;i<a.length();i++){ ch = a.charAt(i); if(ch>='0' && ch<='9'){ sum += (ch-'0'); } } System.out.println(sum); } }
Get Answers For Free
Most questions answered within 1 hours.