java - Calculate day of the week error -


i have wrote program , output isn't working. please me identify error is? have use code not other internet, have construct understood lesson. using jgrasp.

----jgrasp exec: javac -g samooras.java 

the error

samooras.java:25: error: incompatible types: int cannot converted string[]                   -2*(year/100))%7+7)%7+1;                                        ^ 1 error   ----jgrasp wedge2: exit code process 1. 

code:

import java.util.scanner;  public class samooras {     public static void main(string[] args) {         scanner input = new scanner(system.in);         string[] dayoftheweek = {"sat", "sun", "mon", "tues", "wed", "thur", "fri"};         int year = input.nextint();         int month = input.nextint();         int day = input.nextint();         dayoftheweek = ((day +                          (13 * ((month + 9) % 12 + 1) - 1) / 5                          + year % 100                          + year % 100 / 4                          + year / 400                          - 2 * (year / 100)) % 7 + 7) % 7 + 1;         system.out.println("the day of week is: " + dayoftheweek);     } } 

assuming using formula day of week array created, in do:

import java.util.scanner;  public class samooras {     public static void main(string[] args) {         scanner input = new scanner(system.in);         string[] dayoftheweekarray = {"sat", "sun", "mon", "tues", "wed", "thur", "fri"};         int year = input.nextint();         int month = input.nextint();         int day = input.nextint();         int dayoftheweeknumber = ((day +                                     (13 * ((month + 9) % 12 + 1) - 1) / 5                                    + year % 100                                    + year % 100 / 4                                    + year / 400                                    - 2 * (year / 100)) % 7 + 7) % 7 + 1;         string dayoftheweek = dayoftheweekarray[dayoftheweeknumber];          system.out.println("the day of week is: " + dayoftheweek);     } } 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -