#Need a counter for my for loop
15 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @ocean rivet! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
my for loop is
{
for(int b = 1; b < a ; b++)
System.out.println(b);
}
the rest of my code is
public class Methods {
public static int summer (int[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Type one number: ");
int a=scan.nextInt();
{
for(int b = 1; b < a ; b++)
System.out.println(b);
}
return a;
}
public static void upRev (String[] args)
{
}
}
What's the counter for?
Something like: int count = 0 before your for-loop then inside your for-loop's body after the "println" statement add: "count++;"
👀
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
Ty
Gotta return it and add each number from one to the parameter
The parameter being a
@quasi ocean