Title: Java programming course I MOOC Helsinki, question about leap year · Issue #534 · OpenSourceHelpCommunity/Questions · GitHub
Open Graph Title: Java programming course I MOOC Helsinki, question about leap year · Issue #534 · OpenSourceHelpCommunity/Questions
X Title: Java programming course I MOOC Helsinki, question about leap year · Issue #534 · OpenSourceHelpCommunity/Questions
Description: Hi, as a beginner I've started working on the MOOC course Java Programming I. However I'm stuck on the question about leap years. According to the instruction: 'A year is a leap year if it is divisible by 4. However, if the year is divis...
Open Graph Description: Hi, as a beginner I've started working on the MOOC course Java Programming I. However I'm stuck on the question about leap years. According to the instruction: 'A year is a leap year if it is divis...
X Description: Hi, as a beginner I've started working on the MOOC course Java Programming I. However I'm stuck on the question about leap years. According to the instruction: 'A year is a leap year if...
Opengraph URL: https://github.com/OpenSourceHelpCommunity/Questions/issues/534
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Java programming course I MOOC Helsinki, question about leap year","articleBody":"Hi, as a beginner I've started working on the MOOC course Java Programming I.\r\n\r\nHowever I'm stuck on the question about leap years.\r\nAccording to the instruction: 'A year is a leap year if it is divisible by 4. However, if the year is divisible by 100, then it is a leap year only when it is also divisible by 400.'\r\nI can find code on the internet to solve this, but the course specifically asks to 'start building the program from a situation in which you can be certain that the year is not a leap year.' I think this means I should rule out all the situations where I can be certain there's no leap year.\r\n\r\nSo the proposed code is:\r\n\r\nScanner reader = new Scanner(System.in);\r\nint number = Integer.valueOf(reader.nextLine());\r\n\r\nif (number % 4 != 0) {\r\n System.out.println(\"The year is not a leap year.\");\r\n} else if (...) {\r\n ...\r\n} ...\r\n\r\nNow I've tried things such as:\r\n\r\n } else if ((number % 400 != 0) && (number % 100 != 0)) {\r\n System.out.println(\"The year is not a leap year.\");\r\n } else if ((number % 400 == 0) && (number % 100 == 0)) {\r\n System.out.println(\"The year is a leap year.\");\r\n } else if (number % 4 == 0) {\r\n System.out.println(\"The year is a leap year.\");\r\n }\r\n }\r\n}\r\n\r\nBut this doesn't work. I know my logic if flawed but I'm not sure where to start in order to solve this problem. \r\n","author":{"url":"https://github.com/Willemijn83","@type":"Person","name":"Willemijn83"},"datePublished":"2024-10-30T15:43:30Z","url":"https://github.com/OpenSourceHelpCommunity/Questions/issues/534"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:40161719-b37f-740f-19d6-1ac61ac4f6ed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84D2:19E4BB:AB8F87:DC6F9C:6B00F6D3 |
| html-safe-nonce | 3ec9be9e8b4a8575383717b742126816e6f1e4f378c51bd6d6740c389ecbe58e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEQyOjE5RTRCQjpBQjhGODc6REM2RjlDOjZCMDBGNkQzIiwidmlzaXRvcl9pZCI6IjMzMTA3OTAxNDkxMDA1OTg5OTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 616d77d8624456e55994e4e73dc569eb1db2dd641e399c117dc0d6a434fc6c0c |
| hovercard-subject-tag | issue:2624520125 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/OpenSourceHelpCommunity/Questions/534/issue_layout |
| twitter:image | https://opengraph.githubassets.com/21cb8e3c2263a5afa0d61f0543ec2d79cb26801893379f627a09e911c9723728/OpenSourceHelpCommunity/Questions/issues/534 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/21cb8e3c2263a5afa0d61f0543ec2d79cb26801893379f627a09e911c9723728/OpenSourceHelpCommunity/Questions/issues/534 |
| og:image:alt | Hi, as a beginner I've started working on the MOOC course Java Programming I. However I'm stuck on the question about leap years. According to the instruction: 'A year is a leap year if it is divis... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Willemijn83 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/OpenSourceHelpCommunity/Questions git https://github.com/OpenSourceHelpCommunity/Questions.git |
| octolytics-dimension-user_id | 23719480 |
| octolytics-dimension-user_login | OpenSourceHelpCommunity |
| octolytics-dimension-repository_id | 78395582 |
| octolytics-dimension-repository_nwo | OpenSourceHelpCommunity/Questions |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 78395582 |
| octolytics-dimension-repository_network_root_nwo | OpenSourceHelpCommunity/Questions |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width