write a program that will evaluate a inputted string,look at first letter,determine if it is a vowel then add 'hp' to the end of inputted string.if the first letter is not vowel then drop the first letter and add 'hp' to the end.

import java.util.*;
class AddHp
{
 public static void main(String args[])
   {
    String s="hp";
    Scanner ab=new Scanner(System.in);
    System.out.println("Enter the value");
    String str=ab.nextLine();
    int len=str.length();
    for(int i=0;i<1;i++)
     {
      char c=str.charAt(i);
     
      if(c=='a'||c=='i'||c=='e'||c=='o'||c=='u')
       {
        String ss=str+s;
        System.out.println(ss);
        }
       else
        {
         for(int j=1;j<len;j++)
          {
           char e=str.charAt(j);
           System.out.print(e);
          }
          System.out.print("hp");
        }
      }
   }
 }
          
   

No comments:

Post a Comment