S
S
Sergey Sergey2021-05-13 13:56:44
Java
Sergey Sergey, 2021-05-13 13:56:44

Will this code be correct?

public class NewCalendar {
      private int year;
      public int getYear(){
          return year;
        }
      public void setYear(int y){
          year = y;
      }
    int year(){
        for(year=2021; year < 2070; year++) {
            System.out.println("  " + year);
        // Подгон февраля под високосный год
        if (year % 4 == 0)  {
            /*days[1] = 28*/
             System.out.println("Високосный год ");
        }
        else {
           System.out.println("Не високосный год ");
        }
            //days[1] = 29; // Високосный
          //return 0;
        }
//}    return year;
          return 0;
    }      

}  
//}



public class NewCalendarTest {
    public static void main(String[] args) {
        NewCalendar nc = new NewCalendar();
        System.out.println(" " + nc.year());
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question