Need help, trying to print strings backwards while ignoring certain things.

To clarify the topic what I mean is I want to spell the words the user inputs backwards while skipping over certain characters. Here's my code:
import javax.swing.*;
import java.util.*;
import java.text.*;
import java.io.*;
class SConvert{
private static final char BLANK = ' ';
private static final String stop = "STOP";
public static void main(String[] args){
char[] ignore = new char[21];
ignore[0] = '.';
ignore[1] = '/';
ignore[2] = '>';
ignore[3] = '<';
ignore[4] = ',';
ignore[5] = '?';
ignore[6] = '-';
ignore[7] = '~';
ignore[8] = '!';
ignore[9] = '@';
ignore[10] = '#';
ignore[11] = '$';
ignore[12] = '*';
ignore[13] = '&';
ignore[14] = '^';
ignore[15] = '%';
ignore[16] = '`';
ignore[17] = '_';
ignore[18] = '+';
ignore[19] = '=';
ignore[20] = '|';
String word, statement, append;
boolean go = true;
int i, numOfchar, index;
char[] chr;
index = 0;
word = " ";
statement = " ";
append = " ";
Scanner scanner = new Scanner(System.in);
while (go){
System.out.println("Enter a word");
word = scanner.next();
chr = word.toCharArray();
numOfchar = word.length();
if (word.equals(stop)){
     break;
else if (index < numOfchar && word.charAt(index) == BLANK + BLANK){
     index = BLANK;
else if (index < numOfchar && word.charAt(index) == (int)ignore[19]){ //Trying to range for entire array, I don't know how.
     index++;
else
       for (i = word.length() - 1; i >= 0; i--)
          statement = statement + chr;
          append = append + " " + statement;
System.out.print(append + " ");
What's messing me up is the fact that whenever I try to enter words into the program, printing append only repeat EVERY occurance of statement. For example, say I type in "Ham with gravy." I get "maH htiwmaH yvarghtiwmaH".
That's not what I want. Also, I don't know how to make the entire array of ignore available to the program, anyway to do that?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Wow. What's with the hostility? Even I was in error of detecting anything that could have solve the problem completely there's no need to use such a negative tone, epsecaility with someone who is learning to program in OOP, let alone the syntax of Java. Also, no your program did not solve all of my problems in it's original form. Let's take a look at it.
Here's your code:
import java.lang.String;
import java.util.*;
public class ReverseString {
  public void ReverseString(){
  public void printReverse(String s){
     int i;
    String noPrint = "no print'";
    char ch = '*';
    if(s.length()>1) printReverse(s.substring(1));
     ch = s.charAt(0);
    if (!noPrint.contains(ch + " ")) System.out.print(ch);
    return;
  public static void main(String[] args) {
      String myString = Here is my String.;
   System.out.print("My String: " + myString + " Reverse: ");
   new ReverseString().printReverse(add);
   System.out.println();
}In it's original state the program doesn't allow for any user input, which is something I needed (and added on my own), it doesn't convert the ignore[] I had in my original code to anything readable (however this can be done in the noprint String quite easy as someone else mentioned earlier.) the if command does in fact ignore the special characters in noprint String HOWEVER it doesn' t not print those characters as they would appear in the myString String in the position that it original appeared in (which is the primary problem I am having.) That is the problem with your code and why it is not the complete to soultion to my homework problem. I've modified your code to satisifed all but one of the problems.
Modified:
import java.lang.String;
import java.util.*;
public class ReverseString {
  public void ReverseString(){
  public void printReverse(String s){
     int i;
    String noPrint = "~`!@#$%^&()-=+[{]}\':;?/>.<,'";
    char ch = '*';
    if(s.length()>1) printReverse(s.substring(1));
     ch = s.charAt(0);
    if (!noPrint.contains(ch + " ")) System.out.print(ch);
    return;
  public static void main(String[] args) {
       Scanner scanner = new Scanner(System.in);
      String myString;
      String add = " ";
       while (true) {
   System.out.println("Please input String.");
   myString = scanner.next();
   add = add + myString;
          if (myString.equals("STOP")){
               break;
   System.out.print("My String: " + add + " Reverse: ");
   new ReverseString().printReverse(add);
   System.out.println();
}If you run this code you'll see what am talking about. The only remaining problem, which I am about to restate if you are still unclear of it, is that the noprint String contents are ignored but not printed in the original position. If you are still having trouble understanding what I am talking about then let me show what I got by running the program.
String: Ham with grav?y
Reverse: yvarg htiw maH. [Note the ? is missing.]
By removing the ! in the if command I get:
Reverse: y?varg htiw maH. [Now the ? is in the wrong position.]
It's suppose to be:
String: Ham with grav?y
Reverse: yvarg htiw ma?H.
Secondly, I understand that you are frustrated with my apparent lack of understanding of proper Java tems and syntax but you must keep in mind I am student thus I am not fully aware of java as you are. With that one would expect you to act with a bit more patience, yet you not only took offense to an innocent comment you choose to slander my name and intelligence by erasing your code and calling my understanding of Java, ?ignorant.? I may be less than careful with my choice of words concerning Java but I do understand enough code to know the inner workings of a typical program, so please refrain from calling me ignorant or any variant of this in the future.
I merely asked for help from general populous, do not think I owe you any particular praise for your code even if I find it is not exactly what I desired. I may be new to java but I am not new the message boards. With that said I find your response awfully rude and ask if you to refrain from do so in the future. I'm assuming you are an adult so act least act like someone with a bit of civility. If you were so committed to believing your code was the de facto solution to this problem then you could have simply asked why I say what I said, if had done so and shown me the error of my statement I would have not taken offense. Instead you choose to throw a fit and deleted your code. I do not know if you are like this around other board members but you should at least show courtesy to all members of this forum regardless of their time here.
With that said, I think I've all ready found a solution to this problem I've had. I'll just tell the program to simply count over the position the character is in. That way it will stay in the same position.

Similar Messages

  • I need help trying to print ,move and resize multiple images on a page to print!help!

    can anyone give me to some advice. I was using an older version of photoshop elements where i could position the image i wanted to print on the page. I could resize it, move it around and add more photo's. I print small images that I cut out for jewelry making and need to be able to add 12 small images to a 4x6 print size page. My new elements is not allowing me to do that! I'm frustrated and need help!! thanks!

    It should work just the same as before: create a blank document, place your images on it, then print it. The only difference is that you can't change the position of the image in the print window anymore.

  • Need help trying to print Date

    Im trying to print out the date in this format:
    Tuesday, Nov. 6, 2007
    Not sure how to do it...thanx

    System.out.println() and SimpleDateFormat

  • Emergency! i need help trying to print from light room

    I need to be able to print 4 different images in 2x3 on 4x6 paper. I created a print package with 4 2x3's. but it keeps displaying the same image in all for 2x3's and just print is on 4 different 4x6s... help?

    That is how a picture-package works.  You can make a custom package and drag specific photos into each cell.

  • Need help trying to print from my android tablet

    I downloaded HP eprint and I can print pictures but when I go into my gmail account and bring up a message there seems to be no way to print the message

    Hi,
    If you open the eprint app, there should be a tab that allows you to add your gmail account to eprint and access it through the app - have you tried this?
    "Although I work for HP, I'm speaking for myself and not on behalf of HP"
    "Say "Thanks" by clicking the Kudos Star in the post that helped you.
    --Please mark the post that solves your problem as "Accepted Solution"

  • Need help trying to transfer my information from one iphone to another

    need help trying to transfer my information from one iphone to another

    If you are restoring from an icloud backup you are going to have to erase a content and setting and while in the setup prompts you will get the option to restore from an icloud back...that's the only time you will get the option to restore from an icloud back and that's during setup

  • Need Help in Splitting a String Using SQL QUERY

    Hi,
    I need help in splitting a string using a SQL Query:
    String IS:
    AFTER PAINT.ACOUSTICAL.1..9'' MEMBRAIN'I would like to seperate this string into multiple lines using the delimeter .(dot)
    Sample Output should look like:
    SNO       STRING
    1            AFTER PAINT
    2            ACOUSTICAL
    3            1
    4            
    5            9" MEMBRAIN
    {code}
    FYI i am using Oracle 9.2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    There's this as well:
    with x as ( --generating sample data:
               select 'AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN' str from dual union all
               select 'BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN' str from dual)
    select str,
           row_number() over (partition by str order by rownum) s_no,
           cast(dbms_xmlgen.convert(t.column_value.extract('//text()').getstringval(),1) as varchar2(100)) res
    from x,
         table(xmlsequence(xmltype('<x><x>' || replace(str,'.','</x><x>') || '</x></x>').extract('//x/*'))) t;
    STR                                                S_NO RES                                                                                                
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 1 AFTER PAINT                                                                                        
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 2 ACOUSTICAL                                                                                         
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 3 1                                                                                                  
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 4                                                                                                    
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 5 9" MEMBRAIN                                                                                        
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          1 BEFORE PAINT                                                                                       
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          2 ELECTRIC                                                                                           
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          3 2                                                                                                  
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          4                                                                                                    
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          5 45 caliber MEMBRAIN      
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • I need help getting my printer to work

    I need help getting my printer to work

    http://h30434.www3.hp.com/t5/Printer-Networking-and-Wireless/Want-Good-Answers-Ask-Good-Questions/td...
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • Need help getting new printer hp deskjet 3520 setup for eprint and wireless

    need help getting new printer hp deskjet 23520 stup for eprint and wireless

    Hi Pastorlee7,
    I see that you're having problems setting up your printer.  I would take a look at the document below.
    Hp deskjet 3520
    Let me know how it goes.  

  • HT5622 I need help trying to figure out why I'm not able to purchase anythi iTunes. I changed my password, that didn't help. I changed my payment type, that didn't help. It initially started when my password got disabled. Any advice?

    I need help trying to figure out why I'm not able to purchase anything on iTunes. I changed my password, that didn't help. I changed my payment type, that didn't help. It initially started when my password got disabled. Any advice?

    I need help trying to figure out why I'm not able to purchase anything on iTunes. I changed my password, that didn't help. I changed my payment type, that didn't help. It initially started when my password got disabled. Any advice?

  • Need help trying to use close button and i really like to know why it off

    need help trying to use close button and i really like to know why it off

    And in English? You need to explain better.
    Mylenium

  • This is detailed: I lost my touch pad scroll ability on my desktop when I installed Firefox, I am having a terrible time trying to sync my new Android tablet to my desktop, my desktop Firefox is acting very strangly (I need help trying to use it)

    My Vista Home Premium desktop has not used Firefox for a long time. I just loaded it as well as on my Honeycomb Android. The statement that I made pretty much says what my problem is. I can use both of them at the same time and use a router with the air Verizon card installed.
    I'll repeat my question: This is detailed: I lost my touch pad scroll ability on my desktop when I installed Firefox, I am having a terrible time trying to sync my new Android tablet to my desktop, my desktop Firefox is acting very strangely (I need help trying to use it)

    My Vista Home Premium desktop has not used Firefox for a long time. I just loaded it as well as on my Honeycomb Android. The statement that I made pretty much says what my problem is. I can use both of them at the same time and use a router with the air Verizon card installed.
    I'll repeat my question: This is detailed: I lost my touch pad scroll ability on my desktop when I installed Firefox, I am having a terrible time trying to sync my new Android tablet to my desktop, my desktop Firefox is acting very strangely (I need help trying to use it)

  • I need help trying to activate my new phone online where do i go??

    i need help trying to activate my new phone online where do i go??

    Log in to your MyVerizon (verizonwireless.com) and on the Overview page scroll down to I WANT TO... in the third column of boxes, under DEVICE, the 3rd one down is "Activate or Switch Device".  Click on that and follow the instructions.  If there is an issue, it will instruct you to call customer service or you will be connected to customer service automatically.  Let us know if this works...

  • I need help trying to access my spotlight messages.

    I need help trying to access my spotlight messages.  I type in the persons name and only one text comes up but when I type in words in the text other ones come up.  So what I need to do is get all those text messages if its possible.

    I know the texts are there, but like I said it depends on the spotlight search but I want them all in one.

  • [Locked] Really need help trying to log users

    I really need help trying to show when members have logged in.  This is my second post and and the code that I was given, didn't work and now I can't get anyone to tell me what is wrong with it.  Here is the code and error message:
    Error message is "Unknown column 'billsmith' in 'where clause'
    Here is the code I am using:
    mysql_select_db($database_connRegister, $connRegister);
    $logged_in_user = "-1";
    if(isset($_SESSION['MM_Username'])) {
    $logged_in_user=$_SESSION['MM_Username'];
    $query_online_now = "UPDATE users SET logged_in='Online', last_login_date=NOW() WHERE user_name=$logged_in_user";
    $online_now = mysql_query($query_online_now, $connRegister) or die(mysql_error()); }
    $query_not_online_now="UPDATE users SET logged_in='Offline' WHERE last_login_date<NOW() - INTERVAL 60 MINUTE";
    $not_online_now=mysql_query($query_not_online_now, $connRegister) or die(mysql_error());
    Can someone please tell me why it isn't working?

    This question has been answered here: http://forums.adobe.com/message/2351465#2351465.
    Locking this thread to avoid duplication. Please reply in the original thread if any further help is needed.

Maybe you are looking for

  • My Apple ID is valid but can't open icloud account how do i proceed?

    My "Apple ID is valid but can't open icloud account" is the message I receive when I try to sign in to icloud so how do i proceed?  I want to install to my ipad and iphone Apple's locator service in my systems, I have a PC for work reasons where I do

  • CSM with Veritas HA geographic redundancy fails over without visible reason

    Hello. Cisco Security Manager shuts down and Veritas fails it over to another site, I have no idea why. It is clean installation without elements. In Veritas engine log I found this: 2013/02/06 12:52:22 VCS INFO V-16-2-13001 (KV-CSM-01-1) Resource(AP

  • Using JDK1.4 with Weblogic 6.1

    Does ne1 know of any documents(Installion Procedure...) available on Using JDK1.4 with Weblogic 6.1 I need to upgrade from JDK 1.3 to 1.4 using Wlserver6.1 Thanks, Lloyd [att1.html]

  • Shuffling 2-dim array

    Hello, i'm working on a game-project for school, now i need a shuffle of an 2-dim array where i've bound imageIcons to. public setRandom () { randomArray  = new int[numberRows][numberCollumns];  for (int i=0; i<(numberRows-1); i++)        for (int j=

  • Table  which stores the changes on a object

    Hi, Could any one tell me a table which stores the changes done to an object ex:Master data info object. I want to know when an particular attribute added to the master data. Thanks in advance