Skip to content

Commit 40be691

Browse files
authored
Add files via upload
1 parent a2a268c commit 40be691

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

JavaArray03.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*Write a Java program that takes TWO string inputs (containing exactly one word in each string) from the user. Concatenate those two strings with a single space in between them. Generate a number which is the sum of all the letters in that concatenated string where A = 65, Z = 90, a = 97, and z = 122. Your task is to print that concatenated string and the number generated from that string.*/
2+
3+
4+
import java.util.Scanner;
5+
public class Task03{
6+
public static void main(String [] args){
7+
Scanner sc= new Scanner(System.in);
8+
String st1=sc.nextLine();
9+
String st2=sc.nextLine();
10+
int sum=0;
11+
System.out.println(st1+" "+st2);
12+
for(int i=0;i<st1.length();i++){
13+
char ch1=st1.charAt(i);
14+
if((ch1>65&&ch1<90)||(ch1>97&&ch1<122)){
15+
int ch= (int)st1.charAt(i);
16+
sum+=ch;}}
17+
for(int i=0;i<st2.length();i++){
18+
char ch1=st2.charAt(i);
19+
if((ch1>65&&ch1<90)||(ch1>97&&ch1<122)){
20+
int ch= (int)st2.charAt(i);
21+
sum+=ch;}}
22+
System.out.println(sum);
23+
}
24+
}

0 commit comments

Comments
 (0)