Results 1 to 11 of 11
  1. #1
    bilak09 is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

    Angry Problems with my source code

    I have two java programs CallConvert.java which is a driver program for ConvertToAddress.java

    when I compile CallConvert.java i get these errors

    callConvert.java:53: ')' expected
    myC.convert(String s);
    ^
    callConvert.java:53: illegal start of expression
    myC.convert(String s);
    ^

  2. #2
    bilak09 is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

    Default CallConvert.java

    This is ConvertToAddress.java

    Java Code:
    //********************************
    // Ryan Bilak
    // 
    // 
    // ConvertToAddress.java
    // 
    //********************************
    
    import java.util.*;
    
    public class ConvertToAddress
    {
    
       //**************************
       // Constants
       //**************************
    
       //**************************
       // Variables
       //**************************
    
       //*************************************************
       // Takes a string of an address information and
       // creates a mailing label.
       //*************************************************
    
       public void convert(String s){
    
          //*******************
          // Constants
          //*******************
    
          //*******************
          // Variables
          //*******************
    
          int tokenNum = 0;
    
    
          StringTokenizer  words = new StringTokenizer(s,":");
    
          while (words.hasMoreTokens())
          {
             if (tokenNum>2){
                System.out.println(words.nextToken());
                tokenNum++; 
             }
             else if (tokenNum == 2){
                System.out.println(words.nextToken() + ", ");
                tokenNum++;
             }  
             else if (tokenNum == 3  ){
                System.out.print(words.nextToken() + " ");
                tokenNum++;
             }
    
          
         
          }      
    
    
       }
    }

  3. #3
    bilak09 is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

    Default CallConvert.java

    This is CallConvert.java

    Java Code:
    //********************************
    // Ryan Bilak
    // CSC 101
    // John Alampi
    // Week 11 ConvertToAddress.java
    // Due April 26th, 2010
    //********************************
    
    import java.util.*;
    
    public class CallConvert
    {
    
       //**************************
       // Constants
       //**************************
    
       //**************************
       // Variables
       //**************************
    
       //*************************************************
       // Takes a string of an address information and
       // creates a mailing label.
       //*************************************************
    
       public static void main (String[] args)
       {
    
          //*******************
          // Constants
          //*******************
    
          //*******************
          // Variables
          //*******************
    
          int tokenNum = 0;
    
          Scanner scanner = new Scanner(System.in);
          ConvertToAddress myC = new ConvertToAddress();
          scanner.useDelimiter();
          String userInput, result;
    
          
          
          System.out.println("\n");
          System.out.println("Enter the address information in the following format.");
          System.out.println("Sam Penn:14 Bridge St.:Hoboken:NJ:01881");
          userInput = scanner.next();
    
          
          myC.convert(String s);
               
    
    
    
          
          
    
       }
    }

  4. #4
    bilak09 is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

    Default Code output

    When you run the driver program CallConvert.java is supposed to output the following based upon userInput

    Sam Penn
    14 Bridge St.
    Hoboken, NJ 01881

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by bilak09 View Post
    I have two java programs CallConvert.java which is a driver program for ConvertToAddress.java

    when I compile CallConvert.java i get these errors

    callConvert.java:53: ')' expected
    myC.convert(String s);
    ^
    callConvert.java:53: illegal start of expression
    myC.convert(String s);
    ^
    When you call a method and pass a parameter, you don't include the parameter's variable type in the method call. For instance, it's not:

    Java Code:
    myC.convert(String s);

    But rather:
    Java Code:
    String myString = "what the heck";
    myC.convert(myString);
    Make sense? Either way, please let us know.

    Much luck!

  6. #6
    bilak09 is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

    Default ...

    I fixed the portion of the code to read

    Java Code:
    myC.convert(userInput);
    however when I run the program the convert method in ConvertToAddress.java does nothing, I do not understand why this is, any help with this would be much appreciated

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Edit: thank you for wasting my time by having me read and study your code and answer a question that has already been answered in a cross-post in another forum. Frequent cross-posting without notification will put you on many folks do-not-help list. You're on your own with this problem. Much luck.

  8. #8
    bilak09 is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

    Default ...

    I posted both of these at the same time because I wasn't sure forum would be more helpful. I'm new to these forums and didn't know that it would cause a problem I'm sorry for the inconvenience.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Questions in both fora are answered by volunteers, and so our time is valuable to us. There's nothing wrong with cross-posting as long as you're open and up-front about it. If you ask someone to put in the effort to try to help you, it's in your and their best interest that everyone know if you have a similar discussion elsewhere so that they don't duplicate the effort. It makes sense. I appreciate your sensitivity to this (as per your apology).

  10. #10
    bilak09 is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

  11. #11
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. How can i add a new count to this source code ?
    By mm2236 in forum New To Java
    Replies: 2
    Last Post: 01-31-2010, 03:32 AM
  2. How can i add a new count to this source code ?
    By mm2236 in forum Advanced Java
    Replies: 1
    Last Post: 01-30-2010, 01:13 PM
  3. Replies: 1
    Last Post: 11-28-2008, 06:27 PM
  4. how to convert source code to xml
    By valery in forum XML
    Replies: 2
    Last Post: 08-06-2007, 08:29 PM
  5. Need a source code
    By vissu007 in forum New To Java
    Replies: 1
    Last Post: 07-05-2007, 07:08 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •