-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF04SumofChars.java
More file actions
28 lines (23 loc) · 834 Bytes
/
F04SumofChars.java
File metadata and controls
28 lines (23 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package DataTypesandVariables;
import java.util.Scanner;
public class F04SumofChars {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int numberOfLines = Integer.parseInt(scanner.nextLine());
int sum = 0;
// for (int i = 0; i < numberOfLines ; i++) {
// char letter = scanner.nextLine().charAt(0);
// int symbol = Integer.parseInt(letter + "");
// sum += symbol;
//}
// System.out.println(sum);
for (int i = 0; i < numberOfLines ; i++) {
char symbol = scanner.nextLine().charAt(0);
int asciiCode =(int) symbol;
//int asciiCode =symbol;
sum += asciiCode;
//sum += symbol;
}
System.out.println("The sum equals: " + sum);
}
}