473,324 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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

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 1451
Rabbit
12,516 Expert Mod 8TB
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.