Results 1 to 20 of 20
  1. #1
    Join Date
    Jul 2011
    Posts
    13
    Rep Power
    0

    Default Inputting arrays to find the average

    Trying to learn how to do arrays but our teacher is away and theres no way any of us can figure this out. I have a pseudocode of how it should be written and thats all.

    Java Code:
    Pseudocode	
    		
    TeamHeight
    	Set totalHeight to zero
    Set arrayElements to 11
    	DOWHILE  index = 0 to arrayElements 
    		Prompt user for height
    		Get height(index)
    		totalHeight = totalHeight + height(index)
    		display height(index)
    	ENDDO
    	Compute averageHeight = totalHeight/arrayElements
    	Display averageHeight
    END
    Any help would be appreciated.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Instead of posting your pseudocode, try writing the code, compiling it and running it. If it doesn't work then post your code, include all error messages (full and exact, no paraphrasing) and ask a specific question.

  3. #3
    Join Date
    Jul 2011
    Posts
    13
    Rep Power
    0

    Default

    We don't know how to write it because we are ****** retarded and our teacher is away.
    Last edited by Fubarable; 07-28-2011 at 04:44 AM. Reason: obscenity removed

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by DuncanHollows View Post
    We don't know how to write it because we are ******* retarded and our teacher is away.
    We'd rather see an attempt than an excuse. Please at least try.

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Really.

    You don't even know how to write a class? Or a loop? Or a print statement? Or any other legal Java syntax. You might not know how to write the complete program but you should know how to do individual snippets. If you do then try building it up a small piece at a time. If you don't then go back and read your course material. I'm sure your teacher would not set an assignment for material that has not been covered.

    Also, do you really think that people will be encouraged to help you if you swear at them.

  6. #6
    Join Date
    Jul 2011
    Posts
    13
    Rep Power
    0

    Default

    can someone please just tell HOW THE **** to make an array which stores users input
    Last edited by DarrylBurke; 07-28-2011 at 08:39 AM. Reason: Obscenity removed

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by DuncanHollows View Post
    can someone please just tell HOW THE **** to make an array which stores users input
    First put your effort first of all mate. Then post the relevant if you are stuck on anything. Have you tried anything?
    Last edited by DarrylBurke; 07-28-2011 at 08:39 AM. Reason: Obscenity removed

  8. #8
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    If you want the answers try rent a coder, at this site we will help if you try.

  9. #9
    Join Date
    Jul 2011
    Posts
    13
    Rep Power
    0

    Default

    Instead of wasting time telling me to do something why can't you just help.

  10. #10
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Because we are here to help, not do your homework. If you are not interested in learning the material you should either drop the class, or get the grade you deserve(F). If you genuinely want help, why not try something and post what you came up with here? If you are inexperienced we will help you out as long as you are willig to do some work.

  11. #11
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Quote Originally Posted by DuncanHollows View Post
    can someone please just tell HOW THE **** to make an array which stores users input
    I tried to help. I tried to provide advice on the best way to get help. I tried to nudge and guide you into at least making a start. But you seem intent on being nothing more than being rude and ignorant. With that attitude you will not only fail your class but fail in life as well.

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  13. #13
    Join Date
    Jul 2011
    Posts
    13
    Rep Power
    0

    Default

    I don't really know what to do this is all I've got.

    Java Code:
    import cs1.Keyboard;
    public class TeamHeight
    {
        public static void main (String[] args)
        {
            //totalHeight = 0;
            int arrayElements[]={0, 0, 0, 0, 0};
            
            do
            {
                System.out.print("Enter heights");
                Keyboard.readInt();
            }
            while (in counter=0;counter<arrayElements.length)
            {
                System.out.print("Heights:" +index(arrayElements);
            }
                
        }
    }

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  15. #15
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Just looking at your code, I wonder on one thing. How long you are studying Java. Do you have knowledge of any other languages such as C# and so on.

  16. #16
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    At last! You made an attempt at writing the code yourself. Unfourtunately you have wasted your chance as I have no intention of helping you ever!

  17. #17
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default

    Quote Originally Posted by DuncanHollows View Post
    can someone please just tell HOW THE **** to make an array which stores users input
    That's twice you've violated the terms of use of this site. Just once more and your account will be blocked.

    db

  18. #18
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    Man, I'm surprised people are still willing to help you. They gave you good advice when you originally asked, but you want someone to do the work for you. We don't do that here.

    I suggest reading these in order I posted them, I promise you will learn a lot if you actually read them:
    Variables (The Java™ Tutorials > Learning the Java Language > Language Basics)
    Lesson: Classes and Objects (The Java™ Tutorials > Learning the Java Language)
    Arrays (Java Platform SE 6)
    Scanner (Java Platform SE 6)
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  19. #19
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    Remember to increment your counter variable or you'll never get out of that loop thus forcing the program to do something unwarranted, i.e. not work. Hang in there man, and don't give up. I was in your shoes 5 years ago. Nobody helped me, I was bitter, but eventually I just had to train myself to learn it on my own. Then, one day I stumbled across this magical land known as Google and got any development questions answered (seemingly) the same day. All it took was for me to try writing code, building, compiling, debugging, and then (hopefully) running. Remember, as engineers we are not just asking questions, we're guess-and-checking as well. Trial and error is not only a great way to learn, it's also an excellent way to pass the day at work so I can get in my 8 hours. Lastly, check out the The Really Big Index which covers every part of Java known to the universe. ˇBuena suerte!

  20. #20
    stchman's Avatar
    stchman is offline Member
    Join Date
    Apr 2011
    Location
    Saint Louis, Missouri
    Posts
    97
    Rep Power
    0

    Default

    Here is a decent article at Oracle's website that talks about arrays:

    Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)

    There is example code as well.

    Your instructor is talking about arrays and your class has no idea of how to write say a Hello World Java program.

    See, the OP brought ZERO to the table and I didn't do his work for him!!!!!! This is a person that wants someone to do their work for them. I do know the difference.

Similar Threads

  1. Recursively find average of an integer arrray
    By fam2315 in forum New To Java
    Replies: 1
    Last Post: 06-21-2011, 03:25 AM
  2. finding average in 2d arrays
    By the beginner in forum New To Java
    Replies: 18
    Last Post: 02-24-2011, 04:32 AM
  3. Replies: 8
    Last Post: 02-08-2011, 07:27 AM
  4. Sending Arrays into methods then dividing for an average.
    By freebirdcal in forum New To Java
    Replies: 8
    Last Post: 02-03-2011, 10:41 PM
  5. Need help to find average
    By kevinsoto in forum New To Java
    Replies: 4
    Last Post: 11-04-2010, 01:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •