Results 1 to 8 of 8
Like Tree2Likes
  • 2 Post By lenois

Thread: Need help with my program! Please, it's due tomorrow!

  1. #1
    cwill914 is offline Member
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Default Need help with my program! Please, it's due tomorrow!

    My assignment is:

    Write a program which displays the ascii characters between ‘!’ and ‘~’ inclusive with 10 characters per line and one space between the characters. Your program should use a for loop.

    Below is what I have, but when I try to compile it I get this error:

    6 errors found:
    File: C:\Users\User\Documents\Christy School\4-Spring 2013\CSCI\Lab3_2b.java [line: 14]
    Error: not a statement
    File: C:\Users\User\Documents\Christy School\4-Spring 2013\CSCI\Lab3_2b.java [line: 14]
    Error: ';' expected
    File: C:\Users\User\Documents\Christy School\4-Spring 2013\CSCI\Lab3_2b.java [line: 14]
    Error: illegal start of expression
    File: C:\Users\User\Documents\Christy School\4-Spring 2013\CSCI\Lab3_2b.java [line: 15]
    Error: illegal start of expression
    File: C:\Users\User\Documents\Christy School\4-Spring 2013\CSCI\Lab3_2b.java [line: 25]
    Error: <identifier> expected
    File: C:\Users\User\Documents\Christy School\4-Spring 2013\CSCI\Lab3_2b.java [line: 27]
    Error: class, interface, or enum expected
    -------------------------------------------------------------------------------------------

    public class Lab3_2b
    {
    public static void main (String[] args)
    {

    String outputFormat="";
    char ch;
    int ASCIIindex;


    System.out.println () ;
    ASCIIindex = 33;

    for (ASCIIindex <= 126 )
    {
    if (ASCIIindex!=33 && ASCIIindex % 2 == 2)
    System.out.println () ;
    ch = (char) (ASCIIindex);
    outputFormat =ch + " " ;

    System.out.print (outputFormat) ;

    ASCIIindex = ASCIIindex + 1 ;
    }
    System.out.println () ;
    }
    }

  2. #2
    Zyril is offline Senior Member
    Join Date
    Oct 2011
    Location
    Sweden
    Posts
    124
    Rep Power
    0

    Default Re: Need help with my program! Please, it's due tomorrow!

    Hi, you already have the solution displayed by the compiler.


    [line: 14]
    Error: not a statement


    This is NOT how a for-loop should be declared:

    for (ASCIIindex <= 126 )

    Have a look at this:
    The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)

    EDIT:
    Please, use the [CODE]-tags when you post code and it will display more nicely.

    Neither will you print out the characters between ! and ~, since you will include the first one but exclude the last. Look at your values again!
    Last edited by Zyril; 02-10-2013 at 05:56 PM.

  3. #3
    cwill914 is offline Member
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Default Re: Need help with my program! Please, it's due tomorrow!

    Thank you for trying to help. I am a BEGINNER, and a friend helped me get this far, then had to leave. So I was left clueless.

    I just don't understand the for loop (or any of them really), and I can't make it work. I understand it tells me what is wrong, however I don't know what those errors mean either so it's a bit frustrating. My entire class is behind, as our teacher goes really fast, like we should already know this stuff. He is the only teacher that teaches computer science, and my school has no tutoring available, so I'm not really getting the logistics of it. :(

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

    Default Re: Need help with my program! Please, it's due tomorrow!

    Quote Originally Posted by cwill914 View Post
    Thank you for trying to help. I am a BEGINNER, and a friend helped me get this far, then had to leave. So I was left clueless.

    I just don't understand the for loop (or any of them really), and I can't make it work.
    Please calm down and read the tutorials on the for loop. You can find it here: The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)

    If anything in the tutorial isn't clear, then please come back and ask your specific question and let's see how we can help you.

    ... I understand it tells me what is wrong, however I don't know what those errors mean either so it's a bit frustrating. My entire class is behind, as our teacher goes really fast, like we should already know this stuff. He is the only teacher that teaches computer science, and my school has no tutoring available, so I'm not really getting the logistics of it. :(
    Regardless of how good or bad your teacher is, you will learn most by what you study on your own. So please again have a look at the tutorial, continue to write lots and lots of code, and through your efforts it will come to you, almost guaranteed.

  5. #5
    lenois is offline Member
    Join Date
    Feb 2012
    Posts
    59
    Rep Power
    0

    Default Re: Need help with my program! Please, it's due tomorrow!

    Quote Originally Posted by cwill914 View Post
    Thank you for trying to help. I am a BEGINNER, and a friend helped me get this far, then had to leave. So I was left clueless.

    I just don't understand the for loop (or any of them really), and I can't make it work. I understand it tells me what is wrong, however I don't know what those errors mean either so it's a bit frustrating. My entire class is behind, as our teacher goes really fast, like we should already know this stuff. He is the only teacher that teaches computer science, and my school has no tutoring available, so I'm not really getting the logistics of it. :(
    The best way to learn to code, is to code. Do more than the homework, do the exercises in your textbook I understand bad teachers, but you get what your effort gives you. I had never coded before College, and I do every coding challenge I can to help me get the concepts down. It is tough to get the logic when you are not used to it, but it can be done you just need practice.
    Fubarable and DarrylBurke like this.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,419
    Rep Power
    20

    Default Re: Need help with my program! Please, it's due tomorrow!

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

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

    Default Re: Need help with my program! Please, it's due tomorrow!

    He's going to go far.

  8. #8
    Zyril is offline Senior Member
    Join Date
    Oct 2011
    Location
    Sweden
    Posts
    124
    Rep Power
    0

    Default Re: Need help with my program! Please, it's due tomorrow!

    Quote Originally Posted by Fubarable View Post
    He's going to go far.
    And 'tomorrow' is today. Hope he made it not by getting code from someone else!

Similar Threads

  1. Need help ASAP! Problem due tomorrow!
    By ProtoMan in forum New To Java
    Replies: 19
    Last Post: 02-22-2011, 05:00 AM
  2. Replies: 16
    Last Post: 06-27-2010, 04:16 AM
  3. Ordered Array plz help....due tomorrow!!
    By canyonist in forum New To Java
    Replies: 6
    Last Post: 05-23-2010, 09:57 AM
  4. Replies: 10
    Last Post: 02-11-2009, 07:38 AM
  5. Need help~~~ Midterm tomorrow!!!
    By str4kt in forum New To Java
    Replies: 23
    Last Post: 10-10-2008, 09:12 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
  •