Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Java question (noob)

EPPHO
 Share

So I have a homework to write a code to do this (first picture)

 

I did this (2nd picture) and I don't know how to print upwards (if that's a thing, if it's not then I'm doing this the wrong way)

1.JPG

77.JPG

Link to comment
Share on other sites

Link to post
Share on other sites

Or maybe there's a command or something to "reset the position" and start from the 1st row?

Link to comment
Share on other sites

Link to post
Share on other sites

Dont you just have to tell your program to do something like this (just doing some pseudo coding):

Print - x5
Print space x5
Print - x5 (repeat however many times you want this)
Print 4 spaces
Print +
//Do this a couple times..
//And now repeat the above code for the bottom part. So first print spaces and afterwards dashes..

So just print the lines, the plus sign, some spaces, rinse and repeat..

Afterwards print a couple spaces, vertical dash, spaces.. vertical dash.. etc.

and bottom is the same as above, but reverse (spaces, plus, dashes, plus, spaces, etc.)

 

You could probably use some for loops for this to not just repeat "print "-" 5 times.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

35 minutes ago, Minibois said:

Dont you just have to tell your program to do something like this (just doing some pseudo coding):


Print - x5
Print space x5
Print - x5 (repeat however many times you want this)
Print 4 spaces
Print +
//Do this a couple times..
//And now repeat the above code for the bottom part. So first print spaces and afterwards dashes..

So just print the lines, the plus sign, some spaces, rinse and repeat..

Afterwards print a couple spaces, vertical dash, spaces.. vertical dash.. etc.

and bottom is the same as above, but reverse (spaces, plus, dashes, plus, spaces, etc.)

 

You could probably use some for loops for this to not just repeat "print "-" 5 times.

Yes I have to use for loops because there are inputs so it'll look different.

 

The thing is that I didn't know that I have to finish the first row then go to second etc. I thought I have to follow the "shape" of the line on the output.

Link to comment
Share on other sites

Link to post
Share on other sites

Consider whats common between the top and bottom lines. Like maybe some are odd and some are even.

If you're interested in a product please download and read the manual first.

Don't forget to tag or quote in your reply if you want me to know you've answered or have another question.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×