473,386 Members | 1,652 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,386 software developers and data experts.

pig latin translator error help

Hello there. i need some help finishing up my pig latin translator program. It compiles fine, but when i run it and try to translate a sentence, it gives me a syntax error and i cannot see the error. i am almost done with it, please help!

Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. import java.util.*;
  3. import java.lang.String;
  4.  
  5. public class IgLatinPay
  6. {
  7.     public static void main(String [] args)
  8.     {
  9.         String temporary = " ";
  10.         String piglatin = " ";
  11.  
  12.         Scanner input = new Scanner(System.in);
  13.         System.out.println("Enter sentence that you want to translate: ");
  14.         String english = input.nextLine();
  15.  
  16.         while(english.indexOf(' ') != -1)
  17.         {
  18.             temporary=english.substring(0,english.indexOf(' '));
  19.             english=english.substring(english.indexOf(' '));
  20.  
  21.             if(temporary.charAt(0)=='a' || temporary.charAt(0)=='e' || temporary.charAt(0)=='i' || temporary.charAt(0)=='o' || temporary.charAt(0)=='u')
  22.             {
  23.                 piglatin=temporary+"way";
  24.                 System.out.println(piglatin);
  25.             }
  26.             else
  27.             {
  28.                 char firstChar = temporary.charAt(0);
  29.                 piglatin=temporary.substring(1,temporary.indexOf(' '))+ firstChar +"ay";
  30.                 System.out.println(piglatin);
  31.             }
  32.             piglatin+=temporary+" ";
  33.         }
  34.     }
  35. }
  36.  
Oct 23 '07 #1
2 3048
Laharl
849 Expert 512MB
Line 29 looks like it has multiple (I can't quite tell how many, it's either 2 or 3) spaces in between the ' ', which would cause an error since it isn't a single character.
Oct 23 '07 #2
r035198x
13,262 8TB
What is the error given by the compiler? It helps to specify these things when posting your questions.
Oct 24 '07 #3

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

Similar topics

17
by: thinkfirst | last post by:
Hello CIWAH ... I want to propose full internationalization of three related websites: http://africadatabase.org/ http://people.africadatabase.org/ http://institutions.africadatabase.org/ My...
23
by: napi | last post by:
Does anybody know if there's any C99 to C89 translator out there, either free or commercial. I searched on Google but couldn't see it so far. Thanks for any tips. Napi
9
by: Andy | last post by:
I am trying to write a for loop that will print all the ISO-Latin characters to a database. However: I am not sure exactly how to go about printing the ISO-Latin character set. Would anyone be...
1
by: Chris Curvey | last post by:
Hey all, I'm trying to write something that will "fail fast" if one of my users gives me non-latin-1 characters. So I tried this: u'\x80' I would have thought that that should have raised...
0
torquehero
by: torquehero | last post by:
Hi, I am using Dreamweaver 2004 MX. I am trying to draw a hotspot on an image to give it a hyperlink. Actually the image has two parts (Login and Register) that will open up 2 different pages....
7
xNephilimx
by: xNephilimx | last post by:
lHi guys! I'm having a little problem that's getting on my nerves, I couldn't find a solution, I also tryed googling it and I found nothing... (my field of expertise is in AS 2 and 3, but I still...
5
by: Bob Nelson | last post by:
My interest in this new topic was piqued by santosh's recent posting concerning the subject of ``diagnostic message'' here in clc. After reading the C99 standard (``n1256.pdf''), I am unclear if...
2
by: forums_mp | last post by:
Facing a design problem here and I'm not sure how to solve this. The system consists of bi-directional communication between a subject communicating with two (at least for now ) listeners. ...
4
paulrajj
by: paulrajj | last post by:
hi everyone, i want to translate my webpage contents from english language to dutch language. is there any language translator class or package available in php? i have searched a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.