Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SumOfDigitsExample1
- {
- public static void main(String args[])
- {
- Scanner sc = new Scanner(System.in);
- //System.out.print("Enter the number: ");
- int countSymbols =Integer.parseInt(sc.nextLine());
- int sum =0;
- for(int symbol=1;symbol<=countSymbols;symbol++) {
- char value =sc.nextLine().charAt(0);
- sum+=(int)value;
- }
- //prints the result
- System.out.printf("The sum equals: %d",sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement