Guys please tell me where l am going wrong ? How come my program isriddled with
ID: 3613734 • Letter: G
Question
Guys please tell me where l am going wrong ? How come my program isriddled with errors and it is not working,Here is my program :
import javax.swing.*;
public class Zellers
{
public static void main (String [] args )
{
int y = Integer.parseInt;//Year as a 4 digit input
int m = Integer.parseInt; //Stores Month
int q = Integer.parseInt ; //day of the month
int k =y % 100;
int j = y/100;
if (m < 3) {
m += 12;
y -= 1;
}
int day = ((q + (((m + 1) *26) / 10) + k + (k / 4) + (j / 4)) +
(5 * j)) % 7;
String DAYS_OF_WEEK ={ 0,1,2,3,4,5,6};
DAYS_OF_WEEK = JOptionPane.showInputDialog ( " What is the day ofthe week");
0=saturday;
1=sunday;
2=monday;
3=tuesday;
4=wedsneday;
5=thursday;
6=friday;
System.output.println (" Enter the date in yyyy-mm-dd");
System.output.println ("The date was"+ DAYS_OF_WEEK[day] );
}
}
Explanation / Answer
importjavax.swing.*; public class { publicstatic void main (String []args ) { int y = Integer.parseInt(JOptionPane.showInputDialog("Enter the year:")); // Yearas a 4 digit input int m = Integer.parseInt(JOptionPane.showInputDialog("Enter the month:")); //Month int q = Integer.parseInt(JOptionPane.showInputDialog("Enter the day:")); // dayof the month int k = y% 100;//year int j = y/100;// century if (m < 3) { m+=12; y-= 1; } int day = ((q+ (((m +1) * 26) / 10) + k+ (k / 4)+ (j /4)) + (5 * j)) % 7; String[] DAYS_OF_WEEK = new String[]{"Saturday","Sunday", "Monday", "Tuesday","Wednesday", "Thursday", "Friday"}; System.output.println ("Thedate was"+ DAYS_OF_WEEK[day]); } }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.