• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Wrap me around

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The output should be: .

This is what mine is: .
So what I need help with is getting the lines of x's to wrap around (the x's are supposed to represent the spaces for now). But I can't think of a way to do it. Also I know how to get the date inputs that are above and below, I just need help on the main structure of the calendar right now.
 
Niko Fricker
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just noticed that the pictures aren't posting for some reason, give me a second to figure it out...
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Niko Fricker wrote:
For some reason the pictures aren't working so I uploaded them to imgur so you can see them there. Just follow the links.



The Image tag is for links to image files -- and not to web pages that happens to have images on them.

Alternatively, another option is to upload the images directly to the ranch. On the post creation screen, there should be an "attachment" tag, which will allow you to upload images (no need to use a third party site).

Henry
 
Marshal
Posts: 4501
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Niko Fricker wrote:Just noticed that the pictures aren't posting for some reason, give me a second to figure it out...


I fixed your images.  You need to include the URL to the actual images (.png), not the URL to the web page.
 
Niko Fricker
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for fixing the two pictures, but can anyone tell me what I need to do in order to get my code to wrap back around, and still not be static?
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, isn't the logic simply as follows?

1. Print dashes for one box X number of times (where X is the number of days per row)
2. Print a new line
3. Repeat 1 - 2 however many number of rows you want to print in your calendar.
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to read through some of this thread: https://coderanch.com/t/675952/java/java/Code-Review to get ideas on how to systematically attack your problem. This is just another pattern that you have to figure out an algorithm for, much like what was needed to solve the problem discussed in that other thread.
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ensure you post valid code so that we can help you better, you code has a missing brace "}" at the end of it.
Next, your variable names c,d,f,g are quite confusing and do not show what you intend to do
For the solution, all you need to "wrap around" is to place a new line in your code.
You have already done so for line 20,30.

Hint, its in one of your loops.
 
salvin francis
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Btw, why does your requirement requires days to be 32,33,34,35 ? It's a calendar right ?
Does 9 / 20 refers to 20th September ?
If yes, whats so special about 20 in the expected output ?
 
Niko Fricker
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right now I'm just trying to get the basics of it all down. So I'm basically making a non-static 7x5 box that has stuff inside of it.
 
salvin francis
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Niko Fricker wrote:I'm basically making a non-static 7x5 box that has stuff inside of it.


okay, you should have mentioned early on in the thread so that you would get good quality replies to solve your issue rather than queries for what you want to achieve. So, we are no longer taking about months, days and calendars, we are just taking about drawing a box grid with numbers in it.

Did my hint about the new line help ?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic