answersLogoWhite

0


Best Answer

\* if you copy this program ensure in the if statements are inserted by you manually; copy function does not copy or character*\

import java.io.*;

class PigLatin

{

protected static void main()throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the String: ");

String s=in.readLine(),n="";

char ch;

boolean b=false;

for(short i=0;i<s.length();i++)

{

ch=s.charAt(i);

if(ch=='A'ch=='E'ch=='I'ch=='O'ch=='U'ch=='a'ch=='e'ch=='i'ch=='o'ch=='u')

b=true;

if(b==true)

n+=ch;

}

for(short i=0;i<s.length();i++)

{

ch=s.charAt(i);

if(ch=='A'ch=='E'ch=='I'ch=='O'ch=='U'ch=='a'ch=='e'ch=='i'ch=='o'ch=='u')

break;

n+=ch;

}

n+="ay";

System.out.print("Word in Pig Latin: "+n);

}}

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

AnswerBot

3w ago

Here is a simple Java program that takes a string input from the user and converts it into Pig Latin:

import java.util.Scanner;

public class PigLatinConverter {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.println("Enter a word: ");
        String input = scanner.next();

        String pigLatin = input.substring(1) + input.charAt(0) + "ay";
        System.out.println("Pig Latin: " + pigLatin);
        
        scanner.close();
    }
}

This program reads a word from the user, moves the first letter to the end of the word and appends "ay" to it, following the Pig Latin rules.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in java to enter a string and print it in Pig Latin?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a c program using string concept enter a sting and replace the new string in to old string and find no of occurrence?

print c co com comp compu


Write a program that converts a string from small letters to capital letters and vice versa?

Here's a Python program that accomplishes this: def convert_case(input_str): return input_str.swapcase() user_input = input(&quot;Enter a string: &quot;) converted_str = convert_case(user_input) print(&quot;Converted string:&quot;, converted_str)


Write a c plus plus program to read a line from keyboard?

#include &lt;iostream&gt; #include &lt;string&gt; int main() { std::string myStr = ""; std::cout &lt;&lt; std::endl &lt;&lt; "Enter a string: "; std::cin &gt;&gt; myStr; system("PAUSE"); return 0; }


How do you display a text reversely in C language without using onlu simply input and output?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { char string[20]; int i=0; printf("Enter the string.\n"); while(i&lt;=19) { scanf("%c",&amp;string[i]); i++; } while(i&gt;=0) { printf("%c",string[i]); i--; } getch(); } In this program it is compulsory to enter 20 characters. Now we can write a program in which it is not necessary. #include&lt;stdio.h&gt; #include&lt;conio.h&gt; #include&lt;string.h&gt; void main() { char string[20]; int length; printf("enter the string.\n"); gets(string); length=strlen(string); length--; while(length&gt;0) { printf("%c",string[length]); length--; } getch(); }


How to write a Shell program to find the no of vowels in a text?

clear echo -n "Enter the Name / String:" while : do read name echo $name | awk '{print gsub(/[aeiou]/,"")}' done


Write a c program to count the number of word in a string?

#include&lt;stdio.h&gt; void main() { int cnt=0,i; char str[100]; printf("Enter the string "); scanf("%s",str); for(i=0;i&lt;strlen(str)-1;i++) { if(str[i]==' ') cnt++; } printf("\nTotal no. of word in string = %d",cnt); }


When can you enter robot wars?

Write to the program's producers at the BBC.


Write a program that finds greater of two strings entered by user?

public class StringLength { public static void main(String args[]) { String firstString; String secondString; System.out.println("Please enter string (group of characters) "); firstString=sc.nextString(); System.out.println("Please enter second string (group of characters) "); secondString=sc.nextString(); if(firstString&gt;secondString) { System.out.println(); //create blank line System.out.println("First String is greater than the second string"); System.out.println(); } else { System.out.println("Second string is greater than the first string"); System.out.println(); } }//closes the main method }//closes the class.


Write a program to input a string in the form of name and swap the initials of the namefor example enter a string is rohit Kumar sharma and should be printed RK Sharma?

Get the string from user , then U Split the string with space and put in a string array .Then Find Length of string array , Take first letter of each element in array, Except last. Assigned those to a string, then Fetch Last element of an array, Add it With that String.That's it.


Write c program to enter a string it has to display with space?

#include #include using std::cin;using std::cout;using std::endl;using std::string;using std::getline;int main(){string myStr = "";cout


Write a program to accept two string and display weather they are identical or not?

I assume the program should be case-sensitive. Here is a code of such program:#include #include int main() {char str1[100];char str2[100];printf("Please enter first string: ");gets(str1);printf("Please enter second string: ");gets(str2);if (strcmp(str1, str2) == 0) {printf("Strings are Equal.\n");} else {printf("Strings are Not Equal.\n");}return 0;}Testing:Please enter first string: APlease enter second string: AStrings are Equal.Please enter first string: aPlease enter second string: AStrings are Not Equal.If you want to make not case-sensitive comparing before checking you should make both string in lowercase or uppercase.Here is how it should look:#include #include #include void upString(char *str);int main() {char str1[100];char str2[100];printf("Please enter first string: ");gets(str1);printf("Please enter second string: ");gets(str2);upString(str1);upString(str2);if (strcmp(str1, str2) == 0) {printf("Strings are Equal.\n");} else {printf("Strings are Not Equal.\n");}return 0;}void upString(char *str) {register int ind = 0;while (str[ind]) {str[ind] = toupper(str[ind]);ind++;}}Testing:Please enter first string: aaaPlease enter second string: AAAStrings are Equal.Please enter first string: aaaPlease enter second string: aAaStrings are Equal.Note: You should not be using gets() function in real-world application. There is no way you can limit number of characters to read thus allowing to overflow buffer. It was used only for example.


How to write a C program for concatenation of two strings using stack?

#include #include using std::cin;using std::cout;using std::endl;using std::string;int main(void){string str1 = "nothing here";cout str1;string str2 = "neither here";cout str2;string srt = "result here";cout