• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Quick Question on a Numerology Report

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a post from http://www.dreamincode.net/forums/topic/143081-numerology-report/ - I couldnt figure out how to quote it. Basically what i am trying to figure out is how to make required user input in the format, mm / dd / yyyy with spaces before and after the dashes.




Thanks!
 
Bartender
Posts: 612
7
Mac OS X Python
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok,

Do you really want the user to input MMb/bDDb/bYYYY (where b is blank or space)

OR

Do you simply want the report to output as above?


If you want to user to input spaces, why?

-steve
 
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ti Ru wrote:Basically what i am trying to figure out is how to make required user input in the format, mm / dd / yyyy with spaces before and after the dashes.


That code assumes there will be no spaces around the slashes (not dashes).
So if you want the user to enter spaces then you need to change lines 32 - 44 of your code.
The length of the line will no longer be 10 and you will have to check for spaces either side of where you currently set the values of symbol and symbol2.

Having said all that, you would actually be better off looking at the SimpleDateFormat class which will do all of this for you.
 
Ti Ru
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its a requirment for the class. How would i go about accounting for the spaces before and after the dashes? Would the below code work?

mm / dd / yyyy
012345678910111213


 
Marshal
Posts: 80069
410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch and well done finding the code button. But your indentation is inconsistent and you have too many blank lines. We have some suggestions about indentation, etc. You will find more help if you look at the first and second links in this previous post.

I shall see if I can improve your indentation, as well as breaking the longer lines, so you can see the way to do it.
 
Campbell Ritchie
Marshal
Posts: 80069
410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried to improve the indentation.
Why are all your methods static? You should create a field for date (or day month year) and use non‑static methods.
Don't call the Birthday method so often. Make the check method return a boolean for valid date, and you can then call the method once in a loop. The methods should be called birthday and check, by the way.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ti Ru wrote:Would the below code work?


Have you tested it ?
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic