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 () ;
}
}
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!
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. :(
Re: Need help with my program! Please, it's due tomorrow!
Quote:
Originally Posted by
cwill914
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.
Quote:
... 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.
Re: Need help with my program! Please, it's due tomorrow!
Quote:
Originally Posted by
cwill914
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.
Re: Need help with my program! Please, it's due tomorrow!
Re: Need help with my program! Please, it's due tomorrow!
He's going to go far. :(think):
Re: Need help with my program! Please, it's due tomorrow!
Quote:
Originally Posted by
Fubarable
He's going to go far. :(think):
And 'tomorrow' is today. Hope he made it not by getting code from someone else!