Maksud3

part5

Nov 26th, 2020
603
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.epam.rd.java.basic.practice1;
  2.  
  3. public class Part5 {
  4.  
  5.     public static void main(String[] args) {
  6.         int sum = 0;
  7.         try {
  8.             int number = Integer.parseInt(args[0]);
  9.             if (number > 0) {
  10.                 for (char digit : args[0].toCharArray()) {
  11.                     sum += digit - 48;
  12.                 }
  13.             }
  14.         } catch (NumberFormatException ignored) {
  15.         }
  16.         System.out.println(sum);
  17.     }
  18. }
  19.  
RAW Paste Data