#"#" inside square
1 messages ยท Page 1 of 1 (latest)
Here is an AI assisted attempt to answer your question ๐ค. Maybe it helps! In any case, a human is on the way ๐. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
If the "#" characters are overflowing the square, it means that the width of the square is not enough to accommodate all the characters. To fix this issue, you can either increase the width of the square or decrease the number of "#" characters.
Here's an example of how you can adjust the width of the square:
int width = 5; // Adjust this value to change the width of the square
for (int i = 0; i < width; i++) {
for (int j = 0; j < width; j++) {
System.out.print("#");
}
System.out.println();
}
In this example, you can modify the width variable to increase or decrease the size of the square. The inner loop will print "#" characters for each column in a row, and then a new line will be printed to move to the next row.
Alternatively, if you want to decrease the number of "#" characters, you can modify either one or both loop conditions. For example:
int size = 5; // Adjust this value to change the size of each side
for (int i = 0; i < size; i++) {
for (int j = 0; j < size - i; j++) {
System.out.print("#");
}
System.out.println();
}
In this modified example, each row will have one less "#" character than the previous row. The size variable determines how many rows and columns there are in total.
before u go even more complex, write down the logic details on paper
somewhere u should spot your math problem
think over it, this is basic looping around
( and quickly grazing your code, your counting by 1 space, yet your printing 2 items on some occasion, that will mess up your math )
@wispy flint
count your steps
your doing 1 step at a time
yet at some points your printing multiple characterts
say for example 3
so instead of 1 + 1 + 1 + 1
your doing 1 + 3 + 1 + 3 + 1 + 3, just to the point where your +1 reaches its limit
for (int j = 0; j < maxC; j++) {
each +1 u do is a step
now
that is so u max print 80 characters ?
ok, now descent
on how many options are u printing more then 1 character ?
yeah and then the ### aswell
ask yourself why, when your only going 1 character at a time on your counter
say u hit the triple one
instead of ( going to use another char as discord doesnt like it )
u print * * *
however since your hitting multiple characters
your doing * ***
so at position 3, your already waay ahead
instead of being ( ofc its an example ) on 3, your already with your cursor on 6
now if u want to continue with this math approach, u have to place in counters as your display will change all the time. IF your display is a fixed map and will not change,
just use a map or even a hardcoded array with the grid on it
Then its easy to make movement aswell, as u only change the index of an item and the whole map is not affected
where are u stuck ?
what is diffucult ?
its your code no ?
then ask yourself, why am i printing multple things when i'm instructing the code to only print 1 at a time
your going from step 1 to 80
so each step should only have 1 character
your not doing that, so your offsetting fast
@wispy flint
Your question has been closed due to inactivity.
If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.
Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.
When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.
Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.
With enough info, someone knows the answer for sure ๐