473,471 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to make a program repeat until the user types, 'quit', or 'Quit'?

1 New Member
I have to make this program I made able to repeat itself, but I cant figure out how...I'm stuck and need a starting point.

Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2. public class PigLatin 
  3.     {
  4.  
  5.     public static void main(String[] args)
  6.         {
  7.         System.out.println("Type a word in English: ");
  8.         Scanner kb = new Scanner(System.in);
  9.         String englishWord= kb.nextLine();
  10.         if (isVowel(englishWord.charAt(0)))
  11.         {
  12.             System.out.println("Your word in Pig Latin is: " + englishWord + "way");
  13.         }
  14.         else
  15.         {
  16.             for (int i=1;i<englishWord.length();i++)
  17.                 {
  18.                 if (isVowel(englishWord.charAt(i))||englishWord.charAt(i)=='Y'||englishWord.charAt(i)=='y')
  19.                     {
  20.                     //reverse and append
  21.  
  22.  
  23.                     int endindex = englishWord.length();
  24.                     String partBeforeVowel= englishWord.substring(0,i);
  25.                     String vowelAndPartAfterVowel= englishWord.substring(i, endindex);
  26.                     System.out.println(vowelAndPartAfterVowel+partBeforeVowel+"ay");
  27.                     break;
  28.                     }
  29.                 }
  30.         }
  31.     }
  32.         private static boolean isVowel(char v){
  33.             if (v == 'a' || v == 'e' || v == 'i' || v == 'o' || v == 'u' || v == 'A' || v == 'E' || v == 'I' || v == 'O' || v == 'U')
  34.                 return true;
  35.             else
  36.                 return false;
  37.         }
  38.  
  39. }
  40.  
Jan 21 '15 #1
1 1456
Rabbit
12,516 Recognized Expert Moderator MVP
Use a loop that stops only after the user input is quit
Jan 21 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: refer_to_website | last post by:
My VB.NET web application has a textbox where the user is allowed to enter up to 50 characters. I have a label on the form next to the textbox that tells the user how many remaining characters he...
4
by: Jason Cowsill | last post by:
Hi - I am looking for a way to dynamically alter a textbox WHILE the user is typing in it. One example would be while a user is entering their phone number a dash would be entered automatically...
4
by: Philip Wagenaar | last post by:
I have a program that has to run under the administrator account. But the use that will start the program has it's own (limited) account. How can I run a program under administrator? I'd like...
5
by: scorpion53061 | last post by:
Is there a way that anyone knows to force a vb.net program to shut down and then restart itself?
5
by: kenrocks | last post by:
my problem is to ensure that what the user types for the index of an array is really a digit and not a letter...please answer a.s.a.p. thx:D
5
by: premMS143 | last post by:
I'm having idea in VB 6.0 & HTML. Based on this trying to build a simple web application using ASP.NET 3.5, VB as code behind & SQL 2000 for database. Here, I got one doubt. In the Login Form,...
2
by: premMS143 | last post by:
Hi everyone, I'm using ASP.NET & VB for programming. The problem is restricting the users based on the user types. I've several user types, like Admin, Student, Parent, Coordinator etc. ...
12
by: HiGu | last post by:
Is it possible for a textbox to predict phrase as user types in?I know comboboxes can make it happen but what if I want a text box to do the same and predict string?
2
by: Bisyar khub | last post by:
hello,...i want to make program to square the numbers from 1 to 20. i have written this program, it's running but not giving the required answer.i think it is giving a garbage value...please tell me...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.