• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

help me with this code

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can somebody please help me out, i need this code written for a class of mine but Iam completely stumped!
Its gotta be a program that reads in 0 to n floats from the console and calculates the average of the numbers
Any help with those would be GREATLY appreciated
 
Sheriff
Posts: 9099
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi dude man

Welcome to Javaranch. Please read The JavaRanch Naming Policy and change your display name. You can change it here. Thanks.

Regarding your question, we won't write the code for you and deprive you of a learning experience, but if you tell us what you've done, we can give you some hints on how to proceed.

Also, I'm moving this to the Java in General(beginner) forum.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, i'll give "dude man" (or whatever he is called now ) a start:

which is not so great. probably what is wanted is an interactive program - it runs, and waits for floats to be entered and return to be pressed till something ("q" or "Q") is entered at which point it kicks back the average. anything not a float but still a number is accepted. anything not a number is rejected. would like to see that myself
regs
peter
 
charles atlas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
much thanks
 
peter greaves
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wasn't too bad - hope this helps someone...
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmmm... this assignment looks amazingly familiar.
 
charles atlas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
^^^^^there we go^^^^^
im not albanian, im not thai, and im not chinese. So who am i???
the assignment was too hard for me, so why not ask a fellow grenhorn for some help?
hope you dont mind
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u don't need so many import statements
u can just say import.java.io.*;
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by charles atlas:
^^^^^there we go^^^^^
im not albanian, im not thai, and im not chinese. So who am i???
the assignment was too hard for me, so why not ask a fellow grenhorn for some help?
hope you dont mind


Not at all! I told you guys to use JavaRanch as a resource.
 
charles atlas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
peter greaves- I'am trying out your code and i can input numbers but not average them...
tom paul- ok, didn't want to get you mad or anything!
 
charles atlas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wait, nevermind, i figured it out
 
machines help you to do more, but experience less. Experience this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!