Results 1 to 5 of 5
- 10-18-2012, 01:44 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 2
- Rep Power
- 0
1 do while loop gives me 34 errors? ):
Hey guys! I'm working on an assignment for school, and I need a little bit of help.
This is my current code: [Java] import java.io.*; import java.util.*; public class Assignment{ - Pastebin.com
I want to make it that if the user enters something that is greater than 20 for shape then it outputs "invalid choice"..and it gives the user another try. I have the invalid choice part down, but I can't get it to give the user another try. I tried the do while loop in the "horizontal line" part of the section, it gave me 30 errors, if I take out the loop everything works perfectly fine. Any help appreciated, thanks! :)
- 10-18-2012, 02:00 AM #2
Member
- Join Date
- Jan 2012
- Posts
- 49
- Rep Power
- 0
Re: 1 do while loop gives me 34 errors? ):
Apart from the horrific code formatting, you start the do while loop before you properly start the if statement.
The reason the forum has code tags is so that you can post your code in the forum.
- 10-18-2012, 02:25 AM #3
Member
- Join Date
- Oct 2012
- Posts
- 2
- Rep Power
- 0
Re: 1 do while loop gives me 34 errors? ):
Sorry, this is how we were taught in school...and first time using this forum sorry again!
Can you suggest how I could fix this?
- 10-18-2012, 03:34 AM #4
Member
- Join Date
- Jan 2012
- Posts
- 49
- Rep Power
- 0
Re: 1 do while loop gives me 34 errors? ):
dont start the do while loop inside the conditions of the if statement.
- 10-18-2012, 04:33 AM #5
Member
- Join Date
- Oct 2012
- Location
- Tempe, Arizona
- Posts
- 77
- Blog Entries
- 12
- Rep Power
- 0
Re: 1 do while loop gives me 34 errors? ):
You really need to choose a type of formatting and just stick with it throughout the code. It seems like you change styles about 5 different times.
You do this for part of it:
And then you switch it to something like this:Java Code:for(int c = 0; c<i;c++) { System.out.print("*"); }
And then to this:Java Code:for (int j = 1; j<=spaces;j++ ){System.out.print(" ");}
And I don't even know what this is:Java Code:for(int c=1; c<= length; c++){ System.out.println("*");}
And lastly, to this:Java Code:if (shape == 1) do{ {
I mean, do you get what I am saying?.. I feel like I am going crosseyed trying to make sense of this. You really got to go through this code and fix some of this...Java Code:if (length > 20) {System.out.println("Invalid dimension! The dimension must be between 1 and 20.");}
Stick to a one of these two formatting techniques.
One:
Two:Java Code:if(condition){ ...code... }
It seems like you are trying to save space in all the wrong areas.. I am not trying to be mean, but this is like someone typing English like:Java Code:if(condition) { ...code... }
Ho w iS IT g oING toD aY??
It is VERY hard to read.
Similar Threads
-
First Java Program-Compile Errors (errors are posted)-simple GUI
By cc11rocks in forum AWT / SwingReplies: 4Last Post: 01-04-2011, 12:36 AM -
errors with do while loop
By jforce93 in forum New To JavaReplies: 4Last Post: 02-02-2010, 10:29 PM -
Few errors with for loop/printf
By ks1615 in forum New To JavaReplies: 8Last Post: 03-12-2009, 09:47 PM -
What is the difference between Semantic Errors and Logical Errors?
By tlau3128 in forum New To JavaReplies: 3Last Post: 03-08-2009, 01:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks