You are not required to create a styles file for this assignment but if you wish
ID: 3649369 • Letter: Y
Question
You are not required to create a styles file for this assignment but if you wish to, you may. Your functions are already created for you in the functions.js file. They are showDate, dayNumber and showBirthday. After opening your script, add comments explaining your variables and functions. The variable used for the current date will be defined as null so the currect date will display. Next, write text "Today is" along with any spaces needed. Write the function showDate with the currect date Define your variable which will contain the dayNumber function and the currect date. Define your variable which will contain the birthday = showBirthDay and the variable previously defined. Write "Born today" and the birthday varilable.Explanation / Answer
import java.util.Scanner import javax.swing.JOptionPane; public class BirthdayAndEasterSunday { public static void main (String args[]) { System.out.println("Enter your birthday in digit format (M/D/YYYY): "); Scanner kb = new Scanner(System.in); String birthday = kb.nextLine(); String month = new String(); String day = ""; String year = ""; String monthword = ""; int pos1 = birthday.indexOf("/"); int pos2 = birthday.indexOf("/",pos1+1); month = birthday.substring(0,pos1); day = birthday.substring(pos1+1,pos2); year = birthday.substring(pos2+1); if (month == "1" || month == "01") monthword = "January"; else if (month == "2" || month == "02") monthword = "February"; else if (month == "3" || month == "03") monthword = "March"; else if (month == "4" || month == "04") monthword = "April"; else if (month == "5" || month == "05") monthword = "May"; else if (month == "6" || month == "06") monthword = "June"; else if (month == "7" || month == "07") monthword = "July"; else if (month == "8" || month == "08") monthword = "August"; else if (month == "9" || month == "09") monthword = "September"; else if (month == "10") monthword = "October"; else if (month == "11") monthword = "November"; else if (month == "12") monthword = "December"; else monthword = "'Invalid month'"; System.out.print("Your birthday is on " + monthword + " " + day + "."); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.