Results 1 to 11 of 11
Thread: Problems with my source code
- 04-26-2010, 05:30 AM #1
Member
- Join Date
- Apr 2010
- Posts
- 7
- Rep Power
- 0
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);
^
- 04-26-2010, 05:32 AM #2
Member
- Join Date
- Apr 2010
- Posts
- 7
- Rep Power
- 0
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++; } } } }
- 04-26-2010, 05:33 AM #3
Member
- Join Date
- Apr 2010
- Posts
- 7
- Rep Power
- 0
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); } }
- 04-26-2010, 05:35 AM #4
Member
- Join Date
- Apr 2010
- Posts
- 7
- Rep Power
- 0
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
-
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:
Make sense? Either way, please let us know.Java Code:String myString = "what the heck"; myC.convert(myString);
Much luck!
- 04-26-2010, 05:45 AM #6
Member
- Join Date
- Apr 2010
- Posts
- 7
- Rep Power
- 0
...
I fixed the portion of the code to read
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 appreciatedJava Code:myC.convert(userInput);
-
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.
- 04-26-2010, 05:52 AM #8
Member
- Join Date
- Apr 2010
- Posts
- 7
- Rep Power
- 0
...
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.
-
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).
- 04-26-2010, 06:14 AM #10
Member
- Join Date
- Apr 2010
- Posts
- 7
- Rep Power
- 0
cross post http: http://forums.sun.com/thread.jspa?me...8177�
-
Similar Threads
-
How can i add a new count to this source code ?
By mm2236 in forum New To JavaReplies: 2Last Post: 01-31-2010, 03:32 AM -
How can i add a new count to this source code ?
By mm2236 in forum Advanced JavaReplies: 1Last Post: 01-30-2010, 01:13 PM -
MavenJava - browse source code of all open source projects online
By jirkacelak in forum Java SoftwareReplies: 1Last Post: 11-28-2008, 06:27 PM -
how to convert source code to xml
By valery in forum XMLReplies: 2Last Post: 08-06-2007, 08:29 PM -
Need a source code
By vissu007 in forum New To JavaReplies: 1Last Post: 07-05-2007, 07:08 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks