This week's book giveaway is in the Kotlin forum.We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Liutauras Vilda
• Devaka Cooray
• Jeanne Boyarsky
• Bear Bibeault
Sheriffs:
• Junilu Lacar
• Paul Clapham
• Knute Snortum
Saloon Keepers:
• Ron McLeod
• Tim Moores
• Stephan van Hulst
• salvin francis
• Carey Brown
Bartenders:
• Tim Holloway
• Frits Walraven
• Ganesh Patekar

storing values within a loop

Ranch Hand
Posts: 424
3
really battling with the logic in this for loop exercise

Prompt the user for the number of numbers they want to enter. Read in each of the number. When all the number have been entered display: the average, the highest number, the number that were divisible by 3, and the total

what i cant work out is how to store each user input in a variable within the loop and not allowed to use lists

any push in the right direction would greatly be appreciated

author & internet detective
Posts: 39129
723
Jon,
Start with total. That's the easiest. Could you create a variable outside the loop and update it each time you go through the loop to keep a running total?

Once that works, you can start to think about what variables you would need for the other things in the assignment.

jon ninpoja
Ranch Hand
Posts: 424
3
hi jeanne

yes i realise that i dont need every value stored in a variable
i have just created a total
and total = total + numberAdded