Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Program that accepts n amounts of data

 
rachel morgan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I was wondering how you would write a program in java that accepts a lot of different integers then computes their sum / the min and max values, the count and their sum?

I'm literally stuck at

public class statistics
public static void main (String[] args) {

haha

would double n = 0; work?
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class statistics
public static void main (String[] args) {

haha

would double n = 0; work?

No.

This forum is NotACodeMill, you need to ShowSomeEffort if you want help. If you consider your problem a joke, why would anyone bother trying to help you?
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12097
30
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
step 1:
Forget about programming
step 2:
Get a pencil, some paper, and an eraser
step 3:
write down, in English, how YOU would do this, step by step.
step 4:
revise the above steps, getting more and more specific. eventually, you should get to the point where you could hand the directions off to an 8yr old child, and they could follow them.

only after you have done all the above should you consider writing a line of actual java.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

If Fred’s technique fails (it won’t, though), find said 8‑year‑and ask them how to do it.
You are supposed to do five things there. Total, count, average (I presume that means arithmetical mean), maximum and minimum. Do not attempt all five. Attempt one, get it working, then enhance your application by getting a second functionality working.
Another thing Fred often says is never to write more than 5 lines. Then you run the program in its current state, and see whether it works. it is much easier to divide it into little parts because you can find errors so much faster.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic