Java Newbie Question?

Why Know

New Member
Joined
May 24, 2011
Messages
3
Reaction score
0
Points
1
Please help me out.
I understand most everything in this program,
but there is one bit that's driving me crazy.

Let's say my inputs are year=1800, month=1
On line 95 ---> return (totalNumberOfDays + startDay1800) % 7;
which means (31 + 3) % 7 = 6

On line 72 ---> for (i = 0; i < startDay; i++)
so doesn't this mean for (i=0; i<6; i++)

How can the remainder be 6. I must be reading it wrong but how

import javax.swing.JOptionPane;

public class PrintCalendar
{
public static void main (String[]args)
{

String strMonth = JOptionPane.showInputDialog(null,"Please enter the month","MONTH",JOptionPane.QUESTION_MESSAGE);
int month = Integer.parseInt(strMonth);

String strYear = JOptionPane.showInputDialog(null,"Please enter a year","YEAR",JOptionPane.QUESTION_MESSAGE);
int year = Integer.parseInt(strYear);

printMonth(year,month);
}
//Run - print Title and Body
static void printMonth(int year, int month)
{
printMonthTitle(year, month);

printMonthBody (year, month);
}
//Run - Title Print
static void printMonthTitle(int year, int month)
{
System.out.println(" " + getMonthName(month) + year);
System.out.println("----------------------------");
System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
}
//Validate - Month String
static String getMonthName(int month)
{
String monthName = null;
switch (month){
case 1: monthName = "January"; break;
case 2: monthName = "February"; break;
case 3: monthName = "March"; break;
case 4: monthName = "April"; break;
case 5: monthName = "May"; break;
case 6: monthName = "June"; break;
case 7: monthName = "July"; break;
case 8: monthName = "Ausgust"; break;
case 9: monthName = "September"; break;
case 10: monthName = "October"; break;
case 11: monthName = "November"; break;
case 12: monthName = "December"; break;
}
return monthName;
}
//Run - Body Print
static void printMonthBody(int year,int month)
{
int startDay = getStartDay(year, month);
int numberOfDaysInMonth = getNumberOfDaysInMonth(year, month);


for(int i=0; i<startDay; i++)
{
System.out.print(" ");
}
for(int i=1; i<=getNumberOfDaysInMonth(year, month); i++)
{
if (i<10)
System.out.print(" " + i);
else
System.out.print(" " + i);

if ((i + startDay)%7 == 0)
System.out.println();
}
}
//Validate - which day the date starts on.
static int getStartDay(int year, int month)
{
//On the 1/1/1800 starts on a Wednesday 3 days away from Sunday
int startDay1800 = 3;
int totalNumberOfDays = getTotalNumberOfDays(year, month);

//if the total "number of days + startDay1800 in this case is 3 days" is divisible by seven
return (totalNumberOfDays + startDay1800)%7;
}
//Validate - the total number of days in the year and month
static int getTotalNumberOfDays(int year, int month)
{
int totalDays = 0;
//Add 366 or 365 days if it is more then 1800 year
for(int i=1800; i<year; i++)
if (isLeapYear(i))
totalDays = totalDays + 366;
else
totalDays = totalDays + 365;

//add the days in as each month rows by
for(int i=1; i<month; i++)
totalDays = totalDays + getNumberOfDaysInMonth(year, i);

return totalDays;
}
//Validate - the days for each of the month
static int getNumberOfDaysInMonth(int year, int month)
{
if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
return 31;
if(month==4 || month==6 || month==9 || month==11)
return 30;
if(month==2)
return isLeapYear(year)? 29:28;
else
return 0;
}
//Testing - Leap Year ? True or False
static boolean isLeapYear(int year)
{
return year % 400 == 0 || (year % 4 == 0 && year % 100 !=0);
}
}
Thanks for the answers guys
It still does not answer my question.

Why I worked out the remainder to be 6 for startDay, which would make 1/1/1800 print on Sunday.

However, the calendar is still printing on the right day which is Wednesday. :(
 
Shoutbox
  1. EMSpa_schedule:
    Tomorrow's sneak peek: On Thursday April 17, 2025, our attendants will be Sophie 😘, Cici 😘, Monica 🤩, Ada 😘 and Vicky 😘. Call us at (905) 479-6668 to book!
  2. Lilyspa1:
    Lily Spa :💕💕 Wednesday Schedule 🇮🇳🇮🇳Kajal 23, Punjabi girl 😈GFE & bbbj ❤️❤️Elena ( Latino ) Big Nature Boobs & SuSu ( Asian )Slim , 😍😍Porn Service 🔥Duo 🔥,☎️ 6475318288
  3. Golden Flower Spa:
  4. BlueXado Therapy & Spa:
  5. Pink Flower Spa:
  6. Lilyspa1:
    Lily Spa :💕💕 Wednesday Schedule 🇮🇳🇮🇳Kajal 23, Punjabi girl 😈GFE & bbbj ❤️❤️Elena ( Latino ) Big Nature Boobs & SuSu ( Asian )Slim , 😍😍Porn Service 🔥Duo 🔥,☎️ 6475318288
  7. Lulu1980:
    Phoenix Blossom Spa 🌹🌹🌹 Table shower body scrub Sea Salt Bath👍every day 3 girls 🔥🔥🔥5124 Dundas St W Etobicoke☎️416-817-3366👍 Nice girl Ivy ❤️ Natural Big Boobs 36 DD 😘Sexy body Hot body slide, super enjoyable😘😘😘😘 very provocative service😘😘😘, professional super 。Luna😘 deep tissue massage, back walking has therapeutic effect to loosen bones and relieve muscle pressure and will bring you unexpected service effects, she will
  8. EMSpa_schedule:
    🎉We're open!🎉 Today (Wednesday), our amazing attendants are Yoyo 😍, Opal 😘, Sandy 🤩, Cici 😘 and Carla 🥳. Call us at ☎️ (905) 479-6668 ☎️ to book your favourite and head on over to 7665 Kennedy Road, Unit 4, Markham!
  9. Red Rose Spa:
    🌸 We have 11 hot brown girls today 🌸 MONICA, PRIYA, PAOLA, SASHA, PREETI, ANGELINA, DIYA, ANGEL 🌸 2588 Birchmount 🌸 2 Invergordon 🌸 647-702-8800 🌸 Please visit for a great erotic massage
  10. SL East Spa:
    💆‍♀💖WooHoo Wed💖 Ultimate destination for Asian massages🎉 Two fab spots: Richmond Hill & Oakville✨ Your passport to paradise with 9 enchanting girls fr China, HK, Japan & Korea — 🆕Julia, Cindy, Coco, Luna, Amber, JPN Yui, Tina, Akino & Lucy— ready to pamper you🎁🍁 Ring us 📞647-695-6354 or text us 📱647-578-8169✨ 160 East Beaver Cr., Unit 12, RichmondHill 💰Where Eastern charm meets Western comfort - your bliss awaits🙌
  11. wonderspa:
    🌺🌺Wonder spa,(9421Jane st unit127)call416-5000-800☎️best massage in vaughan,Wednesday RMT available,💄sexy very young girl Joey natural c cup,very good looking nice body slide,really popular 🍎long hair Q Lucy good strong to relax oil massage, Relieve pain and remove stress,more experience 🌹beautiful slim body Cici friendly smile,strong and amazing body slide,give you comfortable warm time🔥🔥
  12. Moneylee:
    All season wellness center : New Young girl big boobs beautiful face deep massage Zoe ,young girl pretty face nice figure Thai deep massage Helen,Young girl big breasted beautiful buttocks charming temperament summer ,Young girl Big breasted saucy naughty Ella , Enchanting sexy petite deep massage Sherry ,address: #5-30 Rambler dr Brampton ,Ontario L6W 1E2☎️4376655510 👅👅🦵🦵👄👄🈵🈵
  13. Moneylee:
    Full season wellness center: Young girl Big-breasted big big butts Aris , Young girl big breasted beautiful buttocks charming temperament big boobs Rose,Young girl big breasted beautiful buttocks charming temperament big boobs Julia ,Young beautiful face sexy body and good deep massage maggie,Enchanting sexy petite deep massage Mary. 🏠 2560 Shepard ave Mississauga unit 1 ☎️ 4379857899 👅👅🈵🈵🦵🦵👄👄
  14. AliceSpa:
    WEDNESDAY at 𝗔𝗟𝗜𝗖𝗘 𝗦𝗣𝗔 416-298-0898, 4915 Steeles Ave. E, Scarborough 3 very nice girls here today. Open 10am to 9pm: APPLE: from Hong Kong, very small body, 5' 100Lbs, petite with natural C Cups, small waist, pretty baby face, smooth skin, very clean. Shaved tight Pu**y, strong professional massage. Available FS bbbj cim cof rim. LUCKY (12pm-9pm): is Vietnamese, small body, busty D cup
  15. HollywoodSpa:
    Wednesday at 🎭𝗛𝗢𝗟𝗟𝗬𝗪𝗢𝗢𝗗 𝗦𝗣𝗔🎭, 4578 Yonge St, Unit 100, North York, ON: NICOLE & SISI. ☎𝟰𝟭𝟲-𝟮𝟮𝟮-𝟱𝟱𝟱𝟰☎ NICOLE is petite, slim and very pretty, with C Cups , long hair & a slim waist. She has nice massage and great services. SISI is a sweet slim beauty, 5’2”, with a beauty ass, excellent massage, and amazing services. Come and see why she is so popular. When you visit 🎭Hollywood
  16. ForeverWarden:
    Wednesday at 🫦❤️🔴🟥♾️𝓕𝓞𝓡𝓔𝓥𝓔𝓡 𝓢𝓟𝓐♾️🟥🔴❤️🫦2190 Warden Ave, Unit 201, Scarborough 𝟰𝟭𝟲-𝟴𝟬𝟬-𝟳𝟴𝟴𝟳: Bella, Cindy & Sasa. Bella is around 5’3” with a thin to medium build, C Cups, and a pleasing personality. She can offer dfk, bbbj and cfs as well as a good massage experience. Cindy is a slim beauty, 5’4”, natural C Cups. Her massage is nice, her services will drive you wild & her finish is a dream
  17. Jenny’s Spa:
    🎉🍒JENNY’S SPA🎉🍒 ✅5170 DUNDAS STREET WEST✅ 👌ETOBICOKE ONTARIO M9A 1C4👌 ☎️( 647-893-5196)☎️Call or Text ☎️( 437-888-3759)☎️Call Only (ETOBICOKE) OPEN 10am to 9pm MONDAY to SUNDAY 🔥✅GRAND OPENING💯NEW GIRLS EVERYDAY🔥EXCELLENT MASSAGE + SERVICE QUEENS NOW AVAILABLE AT JENNY’S SPA FOR ALL YOUR MASSAGE AND SPECIAL EXTRA NEEDS🔥💯😘🔥❤️👌 🔥TWO BEAUTIFUL NEW YOUNG ASIAN GIRLS EVERYDAY🔥 💯REAL PICTURES OF ATTENDANTS💯 🔥💋Limited Time Special Promotion🔥💋 ✅💦30 Minutes Nude
  18. SugarLoveSpa:
    Wednesday at ❤️💙 💜⎝𝗦𝗨𝗚𝗔𝗥 𝗟𝗢𝗩𝗘 𝗦𝗣𝗔⎠💖💗💘: ELLA, SUSAN & TIFFANY. 1270 Finch Ave W (at Keele St), Unit 18. North York, ON ☎ 𝟰𝟯𝟳-𝟯𝟲𝟱-𝟮𝟲𝟴𝟴 ☎ ELLA is a lovely Thai sweetheart, 5’1” with C Cups, smooth skin and a very pleasing attitude. SUSAN is a small, slim & sexy brown girl, only 53 Kgs, with nice boobs and ass, very versatile services. TIFFANY is an amazing slim petite doll
  19. Annie Spa:
    🎉🍒ANNIE SPA🎉🍒 ✅7-1001 SANDHURST CIRCLE✅ 👌SCARBOROUGH ON M1V 1Z6👌 ☎️ (647) 891-9688☎️ ☎️ (416) 291-8879☎️ (FINCH & MCCOWAN) OPEN 9:30am to 9pm MONDAY to SUNDAY 🔥✅NEW MANAGEMENT💯NEW GIRLS🔥🔥 🔥GORGEOUS NEW YOUNG ASIAN GIRLS - TODAY’s ROSTER INCLUDES: 🔥 Feifei😘Our new Taiwanese beauty Feifei specializes in creating an intimate and deeply relaxing massage experience tailored to your desires. Her soft, skilled hands glide effortlessly, easing tension and awakening your senses
  20. bnwellness_wilson:
    We have 4 young girls are working today, young sweet Mia 25’s with curve body open mind and young pretty Vicky 25’s with curve body good massage, young cute Ella good massage and flirty GFE Lina are providing deep tissue and sensual massage, pls call 4163985777 book appointment and walk in always welcome, back entrance and parking available, 350 Wilson Ave North York
  21. Golden Sunshine Spa:
    ✨Click on our Username and FOLLOW US for updates and special services ! ✅ Click Here Today🌸Akame🌸Christina🌸Judy🌸Lynda🌸Isabella Call us ☎ 905 - 265 - 2158☎️ Your ultimate service awaits! ✨
  22. Lulu1980:
    Phoenix Blossom Spa 🌹🌹🌹 Table shower body scrub Sea Salt Bath👍every day 3 girls 🔥🔥🔥5124 Dundas St W Etobicoke☎️416-817-3366👍 Nice girl Ivy ❤️ Natural Big Boobs 36 DD 😘Pink Mini Nipples Hot body slide, super enjoyable😘😘😘😘 very provocative service😘😘😘, professional super 🌹 Luna😘 deep tissue massage, back walking has therapeutic effect to loosen bones and relieve muscle pressure and will bring you unexpected service effects, she will
  23. luckywellness:
    Lucky Wellness Center 4379721888 295 Eglinton Ave E,Unit 7,Mississauga Kiki and Niko work They are all young, beautiful and gentle. They are very good at both deep massage and relaxation massage.
  24. Lulu_Villa_Spa:
    Sami is a gorgeous model type Vietnamese Girl Bella She is Mexican Gorgeous face Natalie she is CBC/filipina mixed Petite girl Sasa friendly Vietnamese girl ☎️647- 446-0886
  25. DareDevil:
    ARIA WELLNESS ♥️ADDRESS: 360 HWY 7, UNIT #6, RICHMOND HILL,647-222-5683 (PHONES CALL ONLY, NO TEXT'N AVAILABLE) ♥️TODAY'S Schedule!♥️ Loaded lineup with Young Beautiful Girls : Cute Cici, Magical Mia and Work out🏋🚴💪 Babe Amy! BUY 10 HOURS (GET 11 HOURS) **TODAY'S PICK OF THE DAY IS MIA**
  26. tango20:
    Milton
  27. EMSpa_schedule:
    Tomorrow's sneak peek: On Wednesday April 16, 2025, our attendants will be Yoyo 🍑, Opal 😍, Sandy 🤩, Cici 🤗 and Carla ❤. Call us at (905) 479-6668 to book!
  28. Gulag107:
    つまもの
  29. Golden Flower Spa:
  30. BlueXado Therapy & Spa:
  31. Pink Flower Spa:
  32. SL East Spa:
    💆‍♀💖Tuesday 💜 Ultimate destination for Asian massages🎉 Two fab spots: SL Richmond Hill & SL West Oakville✨ Your passport to paradise with 9 enchanting girls fr China, HK, Japan & Korea — 🆕 Aliyah, Lucy, Yui, Luna, Coco,Cici, busty Amber, Kelly & Luna — ready to pamper you🎁🍁 Ring us 📞647-695-6354 or text us 📱647-578-8169✨ 160 East Beaver Cr., Unit 12, RichmondHill 💰Where Eastern charm meets Western comfort - your bliss awaits🙌
  33. Golden Sunshine Spa:
    ✨Click on our Username and FOLLOW US for updates and special services ! ✅ Click Here Today🌸Susan🌸Cassy🌸Luna🌸Lynda🌸Brandy Call us ☎ 905 - 265 - 2158☎️ Your ultimate service awaits! ✨
  34. wilson holistic centre:
    💕💕💕Beautiful girls everyday working at 💕💕💕535 Evans Ave☎️☎️☎️416-531-6969💋☎️☎️☎️
  35. AliceSpa:
    TUESDAY at 𝗔𝗟𝗜𝗖𝗘 𝗦𝗣𝗔, 4915 Steeles Ave. E, Scarborough 𝟰𝟭𝟲-𝟮𝟵𝟴-𝟬𝟴𝟵𝟴. 3 Young Beauties Today at Alice Spa. Open 10am to 9pm: AMY is a young, petite short & slim Taiwanese, former dance instructor, firm natural B Cups, pretty face, firm natural titis, super play good, bbbj, cim, rim, dfk, all services. KITTY is a new Korean girl, super busty, small body, new to the business.
  36. wonderspa:
    . 🌺🌺Wonder spa,(9421Jane st unit127)call416-5000-800☎️best massage in vaughan,Tuesday RMT available, Today's special recommendation 💄sexy very young girl Mimi,natural c cup,very good looking nice body slide,really popular 😻 🍎long hair Lucy Q smile,very good strong to relax oil massage, back walk,relief your pain,give you warm and comfortable time,🔥🔥
  37. Lulu_Villa_Spa:
    Natalie she is CBC/filipina mixed Petite school girl Suki From Taiwan, sweet girl Cherry 🍒 From Malaysia Part time School girl Judy is a gorgeous model type Vietnamese Girl ☎️647- 446-0886
  38. bnwellness_wilson:
    We have 4 young girls are working today, young sweet Mia 25’s with curve body open mind and young pretty Vicky 25’s with curve body good massage, young cute Sophia 28’s slime good massage and flirty GFE Lina are providing deep tissue and sensual massage, pls call 4163985777 book appointment and walk in always welcome, back entrance and parking available, 350 Wilson Ave North York
  39. Jenny’s Spa:
    🎉🍒JENNY’S SPA🎉🍒 ✅5170 DUNDAS STREET WEST✅ 👌ETOBICOKE ONTARIO M9A 1C4👌 ☎️( 647-893-5196)☎️Call or Text ☎️( 437-888-3759)☎️Call Only (ETOBICOKE) OPEN 10am to 9pm MONDAY to SUNDAY 🔥✅GRAND OPENING💯NEW GIRLS EVERYDAY🔥EXCELLENT MASSAGE + SERVICE QUEENS NOW AVAILABLE AT JENNY’S SPA FOR ALL YOUR MASSAGE AND SPECIAL EXTRA NEEDS🔥💯😘🔥❤️👌 🔥BEAUTIFUL NEW YOUNG ASIAN GIRLS EVERYDAY🔥 💯REAL PICTURES OF ATTENDANTS💯 🔥💋Limited Time Special Promotion🔥💋 ✅💦30 Minutes Nude Massage with
  40. Moneylee:
    All season wellness center: Young girl big boobs beautiful face deep massage Lucy ,Young girl big boobs beautiful face deep massage Tina ,Young girl big breasted beautiful buttocks charming temperament big boobs Cindy ,Student big boobs buttocks Vicky, Enchanting sexy petite deep massage Sherry ,🏠address: #5-30 Rambler dr Brampton ,Ontario L6W 1E2☎️4376655510 👅👅🈵🈵👄👄🦵🦵
  41. Moneylee:
    full season wellness center: NewYoung girl big breasted beautiful buttocks charming temperament Cherry , Young girl big boobs beautiful face deep massage Anika ,Young beautiful face sexy body and good deep massage Selena ,Young girl big boobs beautiful face deep massage Bobo ,Young girl Big breasted saucy naughty Ella,Enchanting sexy petite deep massage Mary. 🏠 2560 Shepard ave Mississauga unit 1 ☎️ 4379857899 🈵🈵🦵🦵👅👅👄👄
  42. HollywoodSpa:
    Tuesday at 🎭𝗛𝗢𝗟𝗟𝗬𝗪𝗢𝗢𝗗 𝗦𝗣𝗔🎭, 4578 Yonge St, Unit 100, North York, ON: COCO & SISI. ☎416-222-5554☎ COCO is an attractive attendant with nice massage skills & good services. SISI is a sweet slim beauty, 5’2”, with a beauty ass, excellent massage, and amazing services. Come and see why she is so popular. When you visit 🎭Hollywood Spa🎭, you will be treated with tender care
  43. ForeverWarden:
    Tuesday at 🫦❤️🔴🟥♾️𝓕𝓞𝓡𝓔𝓥𝓔𝓡 𝓢𝓟𝓐♾️🟥🔴❤️🫦2190 Warden Ave, Unit 201, Scarborough 𝟰𝟭𝟲-𝟴𝟬𝟬-𝟳𝟴𝟴𝟳: Cindy, Tracy & Vivian. Cindy is a slim beauty, 5’4”, natural C Cups. Her massage is nice, her services will drive you wild & her finish is a dream come true. Tracy is an incredibly cute & pretty Japanese/Taiwanese mixed spinner, about 5’1” and 100 lbs. She is very popular for her exotic massage & services.
  44. Soul Relax Spa:
    ✨ Looking for a relaxing escape? ✅ Click Here Meet🌸Nina🌸Anna🌸KimCall us today for the best treatment and service experience. Click on our Username and FOLLOW US for updates ! Call now ☎ 289 - 298 - 5662☎️ Your ultimate relaxation awaits! ✨
  45. HolidaySpa:
    Tuesday at 🌴😎🌅𝓗𝓸𝓵𝓲𝓭𝓪𝔂 𝓢𝓹𝓪🌅😎🌴3517 Kennedy Rd, Unit 4, Scarborough ☎️𝟰𝟯𝟳-𝟮𝟰𝟳-𝟭𝟭𝟵𝟵☎️: EMMA, YOYO & CINDY. EMMA is a very beautiful slim Chinese honey with C Cups, beauty face, & nice services to drive you wild. YOYO is a slim Chinese lady with a nice bust and narrow waist. Great services. CINDY is a slim & incredibly sexy lady with a smile that will melt your heart
  46. SugarLoveSpa:
    Tuesday at ❤️💙 💜⎝𝗦𝗨𝗚𝗔𝗥 𝗟𝗢𝗩𝗘 𝗦𝗣𝗔⎠💖💗💘: JENNY, MIMI, & TIFFANY. 1270 Finch Ave W (at Keele St), Unit 18. North York. JENNY is a sweet & young Korean girl with C Cups. Very versatile services. MIMI is a slim & busty Asian/Euro mix beauty, 50Kgs & 1M60. Mimi has a very versatile range of services. TIFFANY is an amazing slim petite doll with natural 34C melons, slim waist
  47. Annie Spa:
    🎉🍒ANNIE SPA🎉🍒 ✅7-1001 SANDHURST CIRCLE✅ 👌SCARBOROUGH ON M1V 1Z6👌 ☎️ (647) 891-9688☎️ ☎️ (416) 291-8879☎️ (FINCH & MCCOWAN) OPEN 9:30am to 9pm MONDAY to SUNDAY 🔥✅NEW MANAGEMENT💯NEW GIRLS🔥🔥 🔥GORGEOUS NEW YOUNG ASIAN GIRLS - TODAY’s ROSTER INCLUDES: 🔥 Molly🔥😘Our new quick witted and funny girl Molly is here to entertain you not only with her sensual massage skills but also with her sense of humour and her happy go lucky friendly attitude. Molly, a fair skinned mixed race beaut
  48. Red Rose Spa:
    🌸 We have 11 hot brown girls today 🌸 PAOLA, ASHA, SARIKA, MONIKA, ANGEL, AMANDA, PREETI, ANGELINA, AMMU, KIRAN, SALMA 🌸 2588 Birchmount 🌸 2 Invergordon 🌸 647-702-8800 🌸 Please visit for a great erotic massage
  49. Lulu1980:
    Phoenix Blossom Spa 🌹🌹🌹3 girls 😘Table shower 、body scrub 、 Sea salt bath👍5124 Dundas St W Etobicoke☎️416-817-3366👍 New girl ❗️Young girl Anna so young very good massage ”beautiful curvy hips.”very provocative service😘😘😘, professional super Luna deep tissue massage, has therapeutic effect to loosen bones and relieve muscle pressure and will bring you unexpected service effects, she will bring you a little surprise😍😍😍😍❤️ You are welcome to make an appointment at any
  50. luckywellness:
    Lucky Wellness Center 4379721888 295 Eglinton Ave E,Unit 7,Mississauga Bella and Kiki work
Back
Top