Results 1 to 13 of 13
Thread: P-language
- 10-01-2013, 06:31 PM #1
Senior Member
- Join Date
- Aug 2013
- Location
- Sweden
- Posts
- 163
- Rep Power
- 8
P-language
I found an exercise in a book, that I just can't solve. "In the so called p-language all vowels are duplicated and a p is placed between the two duplicated vowels. Consonants and other characters are not changed. Write a program that reads a text that contains a message written in p-language, and then translates it to English." Can you help me with this? Because I just don't know how to do it :( I tried doing it with character arrays, and then moving the elements around, but as soon as I try to print the array out I just get some strange signs and numbers.
- 10-01-2013, 06:40 PM #2
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: P-language
No code = no help.
"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 10-01-2013, 06:53 PM #3
Senior Member
- Join Date
- Aug 2013
- Location
- Sweden
- Posts
- 163
- Rep Power
- 8
Re: P-language
Java Code:public class Tjena{ public static void main(String[] args){ } }
- 10-01-2013, 07:00 PM #4
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: P-language
You've got to be kidding me!!!!
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 10-01-2013, 07:09 PM #5
Re: P-language
try to print the array out I just get some strange signs and numbers.Java Code:System.out.println("an ID "+ java.util.Arrays.toString(theArrayName));
If you don't understand my response, don't ignore it, ask a question.
- 10-02-2013, 05:21 AM #6
- 10-02-2013, 09:56 AM #7
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
- 10-02-2013, 05:56 PM #8
Senior Member
- Join Date
- Aug 2013
- Location
- Sweden
- Posts
- 163
- Rep Power
- 8
Re: P-language
I apologize for being so rude and disrespectful earlier. Here is the actual code that's not working :(
Java Code:import java.util.*; import javax.swing.*; public class Bajs{ public static void main(String[] args){ String s = JOptionPane.showInputDialog("Enter a sentence or a word"), t = s.toUpperCase(); int removedElements = 0; char text[] = t.toCharArray(); for(int x=0;x<text.length-2;x++){ if(ärVokal(text[x]) && text[x+1] == 'P' && text[x] == text[x+2]){ text = removingElements(text, x); } } JOptionPane.showMessageDialog(null, text); } static boolean ärVokal(char c){ char vokaler[] = {'A', 'E', 'I', 'O', 'U', 'Y', 'Å', 'Ä', 'Ö'}; for(int x=0;x<vokaler.length;x++) if(vokaler[x] == c) return true; return false; } static char[] removingElements(char[] text, int index){ char newarray[] = text; for(int x=index;x<index+3;x++){ for(int y=x;y<newarray.length;y++){ newarray[x] = newarray[x+1]; } } return newarray; } }
- 10-02-2013, 06:05 PM #9
Re: P-language
that's not workingIf you don't understand my response, don't ignore it, ask a question.
- 10-02-2013, 07:09 PM #10
Senior Member
- Join Date
- Aug 2013
- Location
- Sweden
- Posts
- 163
- Rep Power
- 8
- 10-02-2013, 07:15 PM #11
Re: P-language
Do you have a problem speaking english? Perhaps if you used Google translate you could create a better answer.
If you don't understand my response, don't ignore it, ask a question.
- 10-02-2013, 07:47 PM #12
Senior Member
- Join Date
- Aug 2013
- Location
- Sweden
- Posts
- 163
- Rep Power
- 8
Re: P-language
I apologize for not being among the 360 million people on this planet who have English as their native language, but I try to speak it as best as I can.
I tried to do what you said and I did not get any strange signs or numbers anymore, however the characters were output like this for example: [A, M, S, P, P, S], and they did not form the words they were supposed to.Last edited by Zelaine; 10-02-2013 at 07:54 PM.
- 10-03-2013, 12:46 AM #13
Similar Threads
-
Java is an OOP language.
By mysourha in forum New To JavaReplies: 3Last Post: 01-14-2010, 11:15 AM -
How to do to change from a language to an other language?
By Ravanelly in forum New To JavaReplies: 5Last Post: 08-25-2009, 10:41 AM -
Is this the right language?
By rws in forum New To JavaReplies: 9Last Post: 11-15-2008, 04:27 PM -
IDE for new language
By mitra2008 in forum EclipseReplies: 2Last Post: 06-23-2008, 07:43 PM -
V language 0.004
By JavaBean in forum Java SoftwareReplies: 0Last Post: 07-19-2007, 04:18 PM
Bookmarks