[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Program Discussion :: Basics

Home > Programs > Basics

346 / 279

Find all the Word Greater or equals to 3 characters and for Every Character Write The ASCII of First and Last alphabet . Total it and Check Whether the Number is Prime or not.

Example :
ASCII of R : 82
ASCII of M : 77
ASCII of B : 66
ASCII of y : 121

Sum up All these and check Wether its Prime or Not ?

Answer:

import java.util.Scanner;


class dd
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String sentence = sc.nextLine();
        String arr[]=sentence.split(" ");
        int j;
        for(j=0;j=3)
            {
                int first_letter=(int)arr[j].charAt(0);
                int last_letter=(int)arr[j].charAt(arr[j].length()-1);
                System.out.println(first_letter+last_letter);
                int num=first_letter+last_letter;
                boolean flag = false;
        for(int i = 2; i 

Asked In ::

Post Your Answer Here:

Language:

Post Your Reply Here: