aspose file tools*
The moose likes Beginning Java and the fly likes Do while error, I'm going crazy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Do while error, I Watch "Do while error, I New topic
Author

Do while error, I'm going crazy

bue curt
Greenhorn

Joined: Dec 25, 2009
Posts: 14
Hi



So I want to an option for the user if she/he still wants to input another number. But It just would not work

We are not allowed to use "equalsIgnoreCase", just do while, and I cant make it work,

PLEASE HELP
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Bue:

Can you give us the stack trace? That would be very helpful in diagnosing your problem.

John.
bue curt
Greenhorn

Joined: Dec 25, 2009
Posts: 14
Here it is

Athul Shetty
Greenhorn

Joined: Jan 05, 2010
Posts: 1
Hi Bue,

I think you are missing one more try block, thats y you are getting above error.

Regards
Shetty
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Athul:

Please use real words.

John.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I think correcting your indentation would help keep you from going crazy -- and might illustrate the problem.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And saying what the error is *when you post* would be helpful.
R Johnson
Greenhorn

Joined: Jan 05, 2010
Posts: 28

I believe what Athul was trying to say is there is a try at line 16 and is caught at line 33 with catch but there is another catch at line 158 with no other try in the code. I'm not currently at a computer that has an IDE available to quickly test this, but I've searched the code twice and just don't see more than one try statement. However, I am new to Java and I feel since the catch statements are of seperate types one is IOException and the other just Exception they should both be able to be executed with the single try statement. Is it their placeing? Or perhaps too many brackets }? If I had to guess once you catch the try statement you probably should go ahead and declare each catch right then because everything after the catch is no longer affected by the try statement so there would be no way to catch it perse'.
bue curt
Greenhorn

Joined: Dec 25, 2009
Posts: 14


Help please, the program would just give error after error. it says that ";" is expected.


sujith Acharya
Ranch Hand

Joined: Dec 25, 2006
Posts: 60
Hi Bue,

I don't see any try block for the second catch block

that you have written
maitrayi vasishtha
Greenhorn

Joined: Jan 04, 2010
Posts: 9
Remove catch from outside while and put the following statements in try block and write catch block for it.
answer = dataIn.readLine();
x=Integer.parseInt(answer);

I have done this for you as foll. Its working fine.

I have not read your logic completely but I guess you should use array to store the numbers_in_words and find out the index to search and get the the number in words. This logic will work fine for you.



bue curt
Greenhorn

Joined: Dec 25, 2009
Posts: 14
maitrayi vasishtha wrote:Remove catch from outside while and put the following statements in try block and write catch block for it.
answer = dataIn.readLine();
x=Integer.parseInt(answer);

I have done this for you as foll. Its working fine.

I have not read your logic completely but I guess you should use array to store the numbers_in_words and find out the index to search and get the the number in words. This logic will work fine for you.






meh, it did not work.



Im still trying to figure it out
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Reformatting your code with a decent editor will show you that the last "break" is misplaced.


[My Blog]
All roads lead to JavaRanch
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

bue curt wrote:
maitrayi vasishtha wrote:Remove catch from outside while and put the following statements in try block and write catch block for it.
answer = dataIn.readLine();
x=Integer.parseInt(answer);

I have done this for you as foll. Its working fine.

I have not read your logic completely but I guess you should use array to store the numbers_in_words and find out the index to search and get the the number in words. This logic will work fine for you.






meh, it did not work.



Im still trying to figure it out


Bue ,

Put the break in line 147 inside the case 9 , then it will work fine


Thanks,
Sherif
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Do while error, I'm going crazy