**3.4 (Random month) Write a program that randomly generates an integer between 1
and 12 and displays the English month name January, February, …, December for
the number 1, 2, …, 12, accordingly.
public class ProgrammingEx3_4 { public static void main(String[] args) { int number1 = (int) (System.currentTimeMillis() % 12 + 1); String month = ""; switch(number1){ case 1: month = "January"; break; case 2: month = "February"; break; case 3: month = "March"; break; case 4: month = "April"; break; case 5: month = "May"; break; case 6: month = "June"; break; case 7: month = "July"; break; case 8: month = "August"; break; case 9: month = "September"; break; case 10: month = "October"; break; case 11: month = "November"; break; case 12: month = "December"; break; } System.out.println(month); } }
This comment has been removed by the author.
ReplyDeleteNice work. Please how do you colour the keywords in your code? Please reply.
ReplyDeleteThank you for asking the question I use custom css in blogger to highlight the keywords so it seems easier for reader to go through code.
DeleteThank you for your reply. Can you please share the code with me? I'd love to use it on my blog too.
Deleteplease check your email
Delete