TCS Coding 1. The program will recieve 3 English words inputs from STDIN These three words will be read one at a time, in three separate line

1. The program will recieve 3 English words inputs from STDIN

  1. These three words will be read one at a time, in three separate line
  2. The first word should be changed like all vowels should be replaced by *
  3. The second word should be changed like all consonants should be replaced by @
  4. The third word should be changed like all char should be converted to upper case
  5. Then concatenate the three words and print them

Other than these concatenated word, no other characters/string should or message should be written to STDOUT

For example if you print how are you then output should be h*wa@eYOU.

You can assume that input of each word will not exceed more than 5 chars

Test Cases

Case 1

Input

  • how
  • are
  • you

Expected Output : h*wa@eYOU

Case 2

Input

  • how
  • 999
  • you

Expected Output : h*w999YOU

94 comments on “TCS Coding 1. The program will recieve 3 English words inputs from STDIN These three words will be read one at a time, in three separate line”


  • Kusal

    The solution below may be very easy to understand and implement 🙂
    str1 = str(input(“Enter 1st word: “))
    str2 = str(input(“Enter 2nd word: “))
    str3 = str(input(“Enter 3rd word: “))

    vow = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’]

    for i in str1.lower():
    if i in vow:
    str1 = str1.replace(i,”*”)
    for i in str2.lower():
    if i not in vow:
    str2 = str2.replace(i,”@”)
    print(str1+str2+str3.upper())


  • Meghana

    python code:
    vowels={“a”,”e”,”i”,”o”,”u”}
    consonants={“b”,”c”,”d”,”f”,”g”,”h”,”j”,”k”,”l”,”m”,”n”,”p”,”q”,”r”,”s”,”t”,”v”,”w”,”x”,”y”,”z”}
    n1=str(input())
    n2=str(input())
    n3=str(input())
    n4,n5,n6=””,””,””
    for i in n1:
    if i in vowels:
    i=”*”
    n4=n4+i
    else:
    n4=n4+i
    for i in n2:
    if i in consonants:
    i=”@”
    n5=n5+i
    else:
    n5=n5+i

    n6=n3.upper()
    print(n4+n5+n6)


  • Mohak

    Incase anyone looking for python code
    Here it is
    w1 = input()
    w2 = input()
    w3 = input()

    for i in w1:
    if(i==”a” or i==”e” or i==”i” or i==”o” or i==”u” or i==”A” or i==”E” or i==”I” or i==”O” or i==”U”):
    w1 = w1.replace(i,”*”)

    for i in w2:
    if(i==”a” or i==”e” or i==”i” or i==”o” or i==”u” or i==”A” or i==”E” or i==”I” or i==”O” or i==”U”):
    w2 = w2.replace(i,i)
    else:
    w2 = w2.replace(i,”@”)

    w3 = w3.upper()

    print(w1,w2,w3)
    print(“thank me later ;)”)


  • Prep

    string=input(“enter the string”)
    str1, str2, str3-string.split(” “)
    list1=[‘a’, ‘e’,’1′,’o’, ‘u’]
    for i in strl:
    if i in list1:
    str1=str1.replace(i,’*’)
    For j in str2:
    if j not in list:
    str2=str2. replace (j,’@’)
    For k in str3:
    str3=str3.upper ()
    print (strl+atr2+atr3)


  • Sri

    a=input()
    b=input()
    c=input()
    vow=”aeiou”
    s=””
    s1=””
    s2=””
    for i in a:
    if i in vow:
    s+=”*”
    else:
    s+=i
    for i in b:
    if i not in vow:
    s1+=”@”
    else:
    s1+=i
    s2=c.upper()
    print(s+s1+s2)


  • Anubhav

    java code
    import java.util.Scanner;
    import java.lang.*;
    class Name
    {
    public static void main(String args[])
    {
    Scanner sc=new Scanner(System.in);
    String words[]=new String[3];
    System.out.print(“Enter the 3 words :”);
    for(int j=0;j<words.length;j++)
    {
    words[j]=sc.next();
    {
    if(j==0)
    {
    char a[]=words[j].toCharArray() ;
    for(int i=0;i<a.length;i++)
    {
    if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U')
    a[i]='*';
    }

    for(int i=0;i<a.length;i++)
    {
    System.out.print(a[i]);
    }
    System.out.print(" ");
    }
    if(j==1)
    {
    char a[]=words[j].toCharArray();
    for(int i=0;i<a.length;i++)
    {
    if(!(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U'))
    a[i]='@';
    }

    for(int i=0;i<a.length;i++)
    {
    System.out.print(a[i]);
    }
    System.out.print(" ");
    }
    if(j==2)
    {
    char a[]=words[j].toCharArray();
    for(int i=0;i<a.length;i++)
    {
    if(Character.isLetter(a[i])&&Character.isLowerCase(a[i]))
    a[i]=Character.toUpperCase(a[i]);
    }
    for(int i=0;i<a.length;i++)
    {
    System.out.print(a[i]);
    }
    }
    }
    }
    }
    }


  • Riya

    Program in python:
    vowel={‘a’,’e’,’i’,’o’,’u’}
    a=str(input())
    b=str(input())
    c=str(input())
    for x in a:
    if x in vowel:
    a=a.replace(x,’*’)
    for y in b:
    if y not in vowel:
    b=b.replace(y,’@’)
    c=c.upper()
    print(a+b+c)


    • Shinde

      thanks for makes code very easy. but, there is one mistake I solved it.
      how
      999
      you
      Expected Output : h*w999YOU
      the code is correct now.
      vowel={‘a’,’e’,’i’,’o’,’u’}
      numbers={0,1,2,3,4,5,6,7,8,9}
      a=str(input())
      b=str(input())
      c=str(input())
      for x in a:
      if x in vowel:
      a=a.replace(x,’*’)
      for y in b:
      if y in vowel or numbers:
      pass
      else:
      b=b.replace(y,’@’)
      c=c.upper()
      print(a+b+c)


  • Souvik

    word1 = input()
    word2 = input()
    word3 = input()
    l1 = list(word1)
    l2 = list(word2)
    vowels = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’, ‘A’, ‘E’, ‘I’, ‘O’, ‘U’]

    for i in range(0, len(l1)):
    if l1[i] in vowels:
    l1[i] = ‘*’

    for j in range(len(word2)):
    if l2[j] in vowels:
    continue
    else:
    l2[j] = ‘@’

    print(”.join(l1) + ”.join(l2) + word3.upper())


  • mounica

    sir i have question when we have to solve test case two how will the program we wrote will be justified can you kindly explain ?//if possible do help by droping the code in python for the second test case there was no solution in python available//
    Please reach out as soon as possible


  • Pawan

    a=str(input())
    b=str(input())
    c=str(input())

    v=[‘a’,’e’,’i’,’o’,’u’]
    for i in a:
    if i in v :
    r=a.replace(i,’*’)
    for i in b:
    if i not in b :
    s=b.replace(i,’@’)

    last=c.upper()
    final=r + s + last
    print(final)


  • Harmeet

    this is for java
    import java.util.Scanner;

    public class changingwords {

    public static void main(String s[]){
    String s1,s2,s3;
    Scanner sin=new Scanner(System.in);

    s1=sin.nextLine();
    s2=sin.nextLine();
    s3=sin.nextLine();

    System.out.println(s1.replaceAll(“[AaEeIiOoUu]”, “*”)+s2.replaceAll(“[^AaEeIiOoUu]”, “@”)+s3.toUpperCase());

    }
    }


  • Raj

    a=input()
    b=input()
    c=input()
    for i in a:
    if(i==”a” or i==”e” or i==”i” or i==”o” or i==”u” or i==”A” or i==”E” or i==”I” or i==”O” or i==”U”):
    print(“*”,end=””)
    else:
    print(i,end=””)
    for i in b:
    if not (i==”a” or i==”e” or i==”i” or i==”o” or i==”u” or i==”A” or i==”E” or i==”I” or i==”O” or i==”U”):
    print(“@”,end=””)
    else:
    print(i,end=””)
    print(c.upper(),end=””)


    • Aniket

      str1 = input(“Enter 1st word: “)
      str2 = input(“Enter 2st word: “)
      str3 = input(“Enter 3st word: “)

      vowel = ‘aeiouAEIOU’
      conso = ‘bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ’

      for i in str1:
      if i in vowel:
      str1 = str1.replace(i,’@’)
      for j in str2:
      if j in conso:
      str2 = str2.replace(j,’#’)

      str3 = str3.upper()

      print(str1+str2+str3)


    • Hemanth

      l=[‘a’,’e’,’i’,’o’,’u’]
      o=[‘b’,’c’,’d’,’f’,’g’,’h’,’j’,’k’,’l’,’m’,’n’,’p’,’q’,’r’,’s’,’t’,’v’,’w’,’x’,’y’,’z’]
      k=[]
      inp=list(map(str,input().split()))
      for i in inp[0]:

      if i in l:
      print(“i:”,i)
      i=’*’
      k.append(i)
      else:
      k.append(i)

      for j in inp[1]:

      if j in o:
      print(“j:”,j)
      j=’@’
      k.append(j)
      else:
      k.append(j)

      h=inp[2]
      f=h.upper()
      k.append(f)

      sep=”
      print(sep.join(k))