I just started programming with Java the other day, so I don't really know all too much. I am making a program that asks you for a day of the month, month, and year, and then tells you what day of the week that is.
import javax.swing.JOptionPane ; public class ChurchAustinA1Q1 { public static void main(String[] args) { final String PROMPT_DAY = "Enter a day of the month." ; final String PROMPT_MONTH = "Enter a month. " ; final String PROMPT_YEAR = "Enter a year. " ; final String YYYY ; final int DAY ; final int MONTH ; final int CENTURY ; final int YEAR ; final int WEEK; DAY = JOptionPane.showInputDialog(null, PROMPT_DAY) ; MONTH = JOptionPane.showInputDialog(null, PROMPT_MONTH) ; YYYY = JOptionPane.showInputDialog(null, PROMPT_YEAR) ; CENTURY = YYYY.substring(0,2) ; YEAR = YYYY.substring(2,4) ; if ( MONTH < 3 ) { MONTH = MONTH + 12 ; YEAR = YEAR - 1 ; } WEEK = ( ( DAY + ( ( ( MONTH + 1 ) * 26 ) / 10 ) ) + YEAR + ( YEAR / 4 ) + ( CENTURY / 4 ) + ( 5 * CENTURY ) ) ; JOptionPane.showMessageDialog(null, "Week day: " + WEEK ) ; } }
But I get this problem:
C:\Users\Austin\Desktop\ChurchAustinA1Q1.java:24: incompatible types found : java.lang.String required: int DAY = JOptionPane.showInputDialog(null, PROMPT_DAY) ; ^ C:\Users\Austin\Desktop\ChurchAustinA1Q1.java:25: incompatible types found : java.lang.String required: int MONTH = JOptionPane.showInputDialog(null, PROMPT_MONTH) ; ^ C:\Users\Austin\Desktop\ChurchAustinA1Q1.java:27: incompatible types found : java.lang.String required: int CENTURY = YYYY.substring(0,2) ; ^ C:\Users\Austin\Desktop\ChurchAustinA1Q1.java:28: incompatible types found : java.lang.String required: int YEAR = YYYY.substring(2,4) ; ^ 4 errors Tool completed with exit code 1
But if I change those variables to String, then the WEEK equation won't work because those variables need to be int. It's probably something really simple that I'm missing, but I need help.