+ 2

Give me a simple for loop code in creating November month calendar.

16th Nov 2016, 12:04 AM
Vanessa Añasco
Vanessa Añasco - avatar
3 Réponses
+ 5
here is your code: public class Program { public static void main(String[] args){ String txt; for (int i = 0;i <30;i++){ if ((i+1)%7 == 1){ txt = "Tue"; } else if((i+1)%7 == 2){ txt = "Wed"; } else if((i+1)%7 == 3 ){ txt = "Thu"; } else if((i+1)%7 == 4){ txt = "Fri"; } else if((i+1)%7 == 5){ txt = "Sat"; } else if((i+1)%7 == 6){ txt = "Sun"; } else{ txt = "Mon"; } System.out.println((i+1) + " " + txt); } } }
16th Nov 2016, 12:30 AM
Maurizio Urso
Maurizio Urso - avatar
+ 2
Thanks
16th Nov 2016, 12:42 AM
Vanessa Añasco
Vanessa Añasco - avatar
+ 2
Here it is... public class Program { public static void main(String[] args){ String txt; for (int i = 0;i <30;i++) { if ((i+1)%7 == 1) { txt = "Tue"; } else if((i+1)%7 == 2) { txt = "Wed"; } else if((i+1)%7 == 3 ) { txt = "Thu"; } else if((i+1)%7 == 4) { txt = "Fri"; } else if((i+1)%7 == 5) { txt = "Sat"; } else if((i+1)%7 == 6) { txt = "Sun"; } else{ txt = "Mon"; } System.out.println((i+1) + " " + txt); } } }
19th Nov 2016, 7:20 AM
Chetan
Chetan - avatar