Author | Message |
---|---|
kievg3
Posts: 3
|
Posted 08:59 Oct 24, 2019 |
Anyone here know how am i suppose to use the for loop in order to print out the range of years for leap years on Lab 9? I've been stuck on this problem for hours, and I could use some help here. This file that I have attached is my progress so far.
|
RaymondM
Posts: 2
|
Posted 11:06 Oct 24, 2019 |
You have errors here: int l = l.nextInt(); //should be int inp = input.nextInt(); if l = // I don’t believe this needed and I don’t know it’s purpose also you’re incrementing x instead of a in your for loop. |
wcwir
Posts: 75
|
Posted 13:04 Oct 24, 2019 |
Your first problem is the errors, as pointed out in the post above mine. After that: you know how to check whether any given year is a leap year, because we already saw a program that does just that. Now you just to that for multiple years during a single program run. That's where the for-loop comes in. We usually start for loops like so:
But if it suits us, we might start with another number, for example:
In our case, if we have some range of years to check, we could start the loop this way:
So that you can check every year in the range entered by the user and decide what to do with it. |