Uil O.

asked • 05/23/16

How do I loop this code , so that the program repeats it self ?

import java.util.Scanner;

public class pigLatin {

public static void main(String[] args)
{

Scanner tread = new Scanner(System.in); //
String word, pig;
char first;


System.out.print("Please Enter English Word: ");
word = tread.next();
word = word.toLowerCase();
System.out.println(word);

first = word.charAt(0);
if (first == 'a' || first == 'e' || first == 'i' ||
first == 'o' || first == 'u') // vowel
pig = word + "hay";
else
pig = word.substring(1) + word.charAt(0) + "ay";



System.out.println("PIG-LATIN : " + pig);



}
}

2 Answers By Expert Tutors

By:

Alex H. answered • 08/30/16

Tutor
5 (2)

Intro to Programming Tutor (Various Languages)

Laura P. answered • 05/24/16

Tutor
4.7 (39)

Writing Tutor

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.