Results 1 to 5 of 5
  1. #1
    dragone227 is offline Member
    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Default 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! :)

  2. #2
    Reeling is offline Member
    Join Date
    Jan 2012
    Posts
    49
    Rep Power
    0

    Default 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.

  3. #3
    dragone227 is offline Member
    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Default 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?

  4. #4
    Reeling is offline Member
    Join Date
    Jan 2012
    Posts
    49
    Rep Power
    0

    Default Re: 1 do while loop gives me 34 errors? ):

    dont start the do while loop inside the conditions of the if statement.

  5. #5
    penguinCoder is offline Member
    Join Date
    Oct 2012
    Location
    Tempe, Arizona
    Posts
    77
    Blog Entries
    12
    Rep Power
    0

    Default 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:
    Java Code:
    for(int c = 0; c<i;c++)
    {
      System.out.print("*");
    }
    And then you switch it to something like this:
    Java Code:
    for (int j = 1; j<=spaces;j++ ){System.out.print(" ");}
    And then to this:
    Java Code:
    for(int c=1; c<= length; c++){
      System.out.println("*");}
    And I don't even know what this is:
    Java Code:
    if (shape == 1)
      do{
        {
    And lastly, to this:
    Java Code:
    if (length > 20)
      {System.out.println("Invalid dimension! The dimension must be between 1 and 20.");}
    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...

    Stick to a one of these two formatting techniques.
    One:
    Java Code:
    if(condition){
      ...code...
    }
    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:
    Ho w iS IT g oING toD aY??

    It is VERY hard to read.

Similar Threads

  1. Replies: 4
    Last Post: 01-04-2011, 01:36 AM
  2. errors with do while loop
    By jforce93 in forum New To Java
    Replies: 4
    Last Post: 02-02-2010, 11:29 PM
  3. Few errors with for loop/printf
    By ks1615 in forum New To Java
    Replies: 8
    Last Post: 03-12-2009, 10:47 PM
  4. Replies: 3
    Last Post: 03-08-2009, 02:51 AM

Posting Permissions

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