• Post Reply Bookmark Topic Watch Topic
  • New Topic
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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is the best way to write this program

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


how do i make the program print the numbers on his own and then give me average, instead of me typing the number by my self, i have tried all i know but cant get the average after printing the numbers. assist me please
am still novice
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't declare more than one variable per line. Please have a look at our suggestions about formatting, which make the code much easier to read. Thank you for using code tags, but you had them in the wrong place and I have corrected them.

If you want to print each number, or a total, you can add lines to print them all. I suggest you use total / counter rather than writing 10.
I am not sure I understand what you said about typing the numbers. You can read numbers from a file, which you will find about in the Java Tutorials.
 
Ranch Hand
Posts: 250
1
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

emeka malachy wrote:how do i make the program print the numbers on his own and then give me average, instead of me typing the number by my self


I really don't understand what you're asking. Can you please clarify?

emeka malachy wrote:i have tried all i know but cant get the average after printing the numbers.


What do you mean exactly? Once I enter 10 numbers, the average is correctly output.

 
A timing clock, fuse wire, high explosives and a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic