Ask coding questions

← Back to all posts
Need help with a part on a JAVA assignment
mnp (1)

I have the sheet with my assignment attached. I need some help with question 2. I'm not quite sure how to make it go back to 0 once it hits 360. I will try to attach the code I have as well (The second image)


Answered by JoshDaBosh (77) [earned 5 cycles]
View Answer
Commentshotnewtop
JoshDaBosh (77)

I'm not sure what you're program is since it just says "Uploading java.docx", etc. but if it's an integer counter then i would suggest using modular operations.

mnp (1)

@JoshDaBosh I just updated it to pictures instead

JoshDaBosh (77)

@mnp this is c/c++ right? just making sure i give correct help for the right language

mnp (1)

@JoshDaBosh I'm sorry this is Java actually

JoshDaBosh (77)

@mnp oof ok, i'll readapt it then

mnp (1)

@JoshDaBosh Thank you! Sorry about that

JoshDaBosh (77)

@mnp https://repl.it/@JoshDaBosh/some-example
There's no need to set it back to 0, as you can see in the program.
I've added some extra touches to it to make it look better but the core code is lines 22-25 if you already have preset variables times, amt, and inc.

JoshDaBosh (77)

@mnp if you want it to still use a for loop, just nest the for loop in another for loop which counts the amount of times you want to count to 360. It's essentially the same logic that i used but way longer and complicated.