Victoria Li

Greenhorn
+ Follow
since Jan 20, 2018
Victoria likes ...
Eclipse IDE Java Windows
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
4
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Victoria Li

Also, calling printMonth() in printYear() will print out the months, but in a vertical line. Any idea how to make it print in a 4*3 formation (4 down, 3 across)
2 weeks ago
So I've got this code now:



It works for me, but now I need to print out the entire calendar:

printYear(int year, int janFirst, boolean leapYear) is similar.  However, it will indicate special holidays with certain characters:


So, printYear(2013, 2, false) should print:


The special characters (i.e. *p, *v, etc.) should be in red.

Any idea how to add in the special characters using the shortest amount of characters?
2 weeks ago

Piet Souris wrote:A simple way without calculations is to have a 2D array month[][], where the first index is the month, and the second index the number of days in that month. So month[0] = new int[31], month[1] = new int[28/29], et cetera. Then loop through all the months and days, starting with day janFirst.



Oh! I completely forgot about ragged arrays! I'll try that. Thanks
2 weeks ago

Swastik Dey wrote:So your requirement is , considering the given value for Jan you have to display the calendar of given month?



Yep! I just can't get the first day for each month right.
2 weeks ago

Fred Kleinschmidt wrote:Note that it is not necessary for the caller to specify what day January 1 is (not only that, it is just wrong to do so - the caller could easily enter the incorrect day).
Knowing that January 1, 2018 was a Monday, it is not too difficult to deduce what day January 1 is for any specified year.

It is also not necessary to include a parameter that specifies whether it is a leap year (that also allow the caller to make an error).



Sorry, it would be easier to have an automatic calendar that is not based on user input, but that is a requirement of the assignment.
3 weeks ago

Swastik Dey wrote:What value janFirst contain.   Is this fixed value.



No, it depends on what year it is. The user will have to input that value. For example, 2016's janFirst is 5, or Thursday.
3 weeks ago

Swastik Dey wrote:Ok..then even things are getting complicated.  You can use Calendar, class it would be much easier.



Yeah, it would probably be easier to do that, but imports besides java.util.scanner aren't allowed (you can probably feel my pain). I just tried this:

       

In this piece of code, I tried to add the days of each month to 'd'. I then modded it to find the day that the month should start at. However, this still doesn't yield the right days, so I'm unsure how to fix this.
3 weeks ago

Swastik Dey wrote:What is the reason behind starting from January?  Why not start from the 1st of the given month and year itself.



According to my assignment, I'm required to have a user input the day that January 1st is on and figure out the other first days based on January 1st.
3 weeks ago

Swastik Dey wrote:

What is happening in the above line?



I was trying to find the first date of the month, and I think that this is the part of the code that needs work.
3 weeks ago

Swastik Dey wrote:One problem as per my understanding is your return statement is out side the loop, so it will print only when the loop terminates.  You either need some sort of recursive function or the print statement should be inside the loop itself.



I changed the return statement and added a bunch of System.out.print() statements. This is what I have now:



Although the code works for February 2016, it does not seem to do so for most other dates. How am I able to revise this?
3 weeks ago

Campbell Ritchie wrote:That is bad design, I am afraid. It means you have too much code in the main() method.



I don't see how that is. All the main method is doing is executing the two methods printMonth() and printYear().
3 weeks ago

Carey Brown wrote:

Victoria Li wrote:I don't know exactly how to begin. How would I be able to get a user input for the empty and filled spaces in a 200x60 two-dimensional array?


Seems like entering (up to) 200x60 cells would be extremely tedious and error prone. You could instead read a file with the cell configuration. Perhaps something like:
You could have an option to fill in the cells with random booleans. The specs seem to leave it up to you.



That would be a better idea, but I'm required to begin with a 200x60 and have a user input the empty/filled spots.
3 weeks ago

Campbell Ritchie wrote:Why have you got all your class members static?
Have you been through the Java™ Tutorials, because I think you will find lots of useful information there?



All my classes/methods are static because the main method needs to be able to access them. Without the static, the main doesn't recognize them.
3 weeks ago
This is what I have attempted doing:


I don't know exactly how to display all the dates starting from the beginning date of each month. Also, the method I am using to find the first day of each month doesn't seem to work. Is anyone able to help?
3 weeks ago

Jeanne Boyarsky wrote:So what more specific question do you have?



I don't know exactly how to begin. How would I be able to get a user input for the empty and filled spaces in a 200x60 two-dimensional array?
3 weeks ago