Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.epam.rd.java.basic.practice1;
- public class Part5 {
- public static void main(String[] args) {
- int sum = 0;
- try {
- int number = Integer.parseInt(args[0]);
- if (number > 0) {
- for (char digit : args[0].toCharArray()) {
- sum += digit - 48;
- }
- }
- } catch (NumberFormatException ignored) {
- }
- System.out.println(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement