Teacher diego

Number of days in the year

  • 3
  • Locked
  • Exercise
On Earth, a year lasts 365 or 366 days. The number of days is calculated according to the following formula: A leap year (366 days) is every year evenly divisible by 4, except for years that are multiples of 100 but not multiples of 400. We'll write a program that will determine whether the user has entered a leap-year or ordinary year from the keyboard.
You can't complete this task, because you're not signed in.
Comments (12)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
JaimeLevel 4 , Panshanger
19 May, 22:22
I am having issues with verifying the exercises. The days of the week exercise will run on IntelliJ but the server wont accept it, but wont run on the website due to incompatible data types. The days in the year exercise will run on IntelliJ but not on the site, I can't verify on IntelliJ because it says "the package sun.plugin2.gluegen.runtime does not exist" on line 8, the Java.io.*; line. Does this mean that the packages used are outdated? surely it should be "oracle.plugin" or something because Oracle is in control of java now. This, to me, speaks to the plugin not being very good/outdated or a backend problem with the server. I may be wrong I am just a beginner trying to learn this stuff but should it really be this hard to get your work checked. Also should I try to write java for IntelliJ or the website because they don't seem to use the same if an exercise will run on one but not the other. Possibly I'm doing something wrong or haven't set things up correctly because I see people on higher levels than me so they must be able to verify their work. Am I the only one having issues. I have tried using help and a nice person did reply to my question but their suggestion didn't solve the problem. Also in IntelliJ running the solution is annoying, if you have done a couple of exercises, because it doesn't necessarily run the current exercise but may instead run a previous one. This isn't too bad in itself, I just press Ctrl + Shift + F10, but it does mean that I am not sure what exercise is being verified, because I don't know if a keyboard shortcut exists for verify current main. It's got to the point where I am not sure that I want to proceed. If I can't verify that the work is correct what is the point of doing it? These problems are making me start to reconsider using Codegym.
RomanLevel 41
20 May, 06:28
Correct package of this task is:
package com.codegym.task.task04.task0414;
You can run the current code with Ctrl + Shift + F10 or right mouse button click on your code and choose "Run" .
ZibaniLevel 9 , Here
17 February, 05:20
So, did I skip something, or does codegym really like to give projects with features that it never taught how to solve? Like, I solidly do not remember a single lesson discussing the mod operator(%), and yet this expects you to know how to use it effectively. And this is not the first time I've noticed this sort of thing, either. Am I just unobservant, or does this website actually expect you to figure it out just by googling it?
RomanLevel 41
18 February, 06:57
ddiLevel 13 , Dortmund
21 May, 07:01
I have the same idea as you. Not te first time that i´m completly lost on how to solve the problem! Should be good to have a couple more lights :)
SrikumaranLevel 4 , Fort Collins
29 November 2018, 22:10
I guess this is correct but why compiler says "no else with out if" I had the same problem for the other Task in the Level 4 itself. - The syntax is also correct.
RomanLevel 41
30 November 2018, 06:54
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at codegym.cc/help.
veera krishnaLevel 4 , Jakarta
16 September 2018, 14:01
package com.codegym.task.task04.task0414;

/*
Number of days in the year

*/

import java.io.*;

public class Solution {
    public static void main(String[] args) throws Exception {
        //write your code here
       BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String syear = reader.readLine();
        int y = Integer.parseInt(syear);
        if(y%4 == 0){
            if(y%100 == 0){
                if(y%400 == 0) {
                    System.out.println("Number of days in the year: 366");
                }
                System.out.println("Number of days in the year: 365");
            }
            System.out.println("Number of days in the year: 366");
        }
        else {
          System.out.println("Number of days in the year: 365");
        }
    }
}
what was wrong with this code
RomanLevel 41
17 September 2018, 05:22
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at codegym.cc/help.
2 August 2018, 20:21
Top instructions say result should be: "Number of days in the year: x", where x is 366 for a leap year, and x is 365 for an ordinary year. Botom requirements say: 3. If the entered year is a leap year, you should display: "Number of days in a year: 366". 4. If the entered year is not a leap year, you should display: "Number of days in a year: 365". Both ways don't pass the tests.
RomanLevel 41
6 August 2018, 10:47
Thanks, "top instructions" fixed. But "botom requirements" are correct.
6 August 2018, 18:41
Yeah was missing one condition.