-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion9.java
More file actions
38 lines (32 loc) · 790 Bytes
/
Question9.java
File metadata and controls
38 lines (32 loc) · 790 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
29
30
31
32
33
34
35
36
37
38
import java.util.*;
public class Question9 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the letter to encode: ");
String x = sc.next().toUpperCase();
char y[] = new char[x.length()];
for (int i = 0; i < y.length; i++) {
y[i] = x.charAt(i);
}
if (y.length == 1) {
for (int i = 0; i < y.length; i++) {
System.out.println((int) y[i] - 64);
}
} else {
int sum = 0;
int num[] = new int[y.length];
for (int i = 0; i < num.length; i++) {
num[i] = (int) y[i] - 64;
}
for (int i = 0; i < num.length; i++) {
sum += num[i];
}
System.out.println(sum);
}
sc.close();
}
}
/*Satyam Sekhar Barik
* Regd-no : 2141002032
* sec : CSE-U
* */