Results 1 to 5 of 5
  1. #1
    Zebra's Avatar
    Zebra is offline Member
    Join Date
    Apr 2008
    Location
    Louisville, Indiana/Kentucky
    Posts
    64
    Rep Power
    0

    Default [SOLVED] Integers (averages and remainders)...need help

    Hey everybody. I have a new question today that I need help with. Here is the question.

    "Make a program that asks the user to input n-integers. And, find the average of the remainders, when each is divided by 4."

    ...hopefully somebody can help me out. Thanks for your time.

  2. #2
    Zebra's Avatar
    Zebra is offline Member
    Join Date
    Apr 2008
    Location
    Louisville, Indiana/Kentucky
    Posts
    64
    Rep Power
    0

    Default

    Alright my teacher just ended up giving me the code. Lol. Here is the code, and mods you can put solved on the title.

    Java Code:
    import java.util.Scanner;
    class Remainders {
    	public static void main(String args[])
        {
        	Scanner scan = new Scanner(System.in);
        	double avg;
        	double sum = 0;
        	int num;
        	System.out.println("How many numbers?");
        	int n = scan.nextInt();
        	for(int i = 1; i <= n; i++)
        	{
        		System.out.println("Enter number " + n);
        		num = scan.nextInt();
        		sum = sum + num % 4;
        	}
        	avg = sum/n;
        	System.out.println("The average of the remainders is " + avg);
        }
      }
    I am a Java n00b.

  3. #3
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    That's strange.. what is the teacher's purpose is handing out the code like this without a student's attempt ? I question his/her pedagogy. :(
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  4. #4
    Zebra's Avatar
    Zebra is offline Member
    Join Date
    Apr 2008
    Location
    Louisville, Indiana/Kentucky
    Posts
    64
    Rep Power
    0

    Default

    Because that was review and we are having a test today.
    I am a Java n00b.

  5. #5
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Maybe, you forgot to ask a question...

    Hey everybody. I have a new question today that I need help with. Here is the question.

    "Make a program that asks the user to input n-integers. And, find the average of the remainders, when each is divided by 4."
    Maybe, "Can you show a program that is similar to program that i was specified? i like to have an experiment on it to be able to learn java...

    if you feel that you are a noob, well, don't say that....
    You might say, i am a beginner, not a noob...

    And our experts here, are also came from a beginner, so, you have more chance to be an expert too.. like them... just have patience...

    have some experiments on the code, maybe your source is the book or the net....

    write it, predict, code it and realize.
    sukatoa

Similar Threads

  1. Reading Integers from a text file
    By tress in forum New To Java
    Replies: 6
    Last Post: 02-26-2011, 05:45 PM
  2. Finding Median of X Integers
    By Hasan in forum New To Java
    Replies: 3
    Last Post: 08-12-2008, 02:06 PM
  3. Averages of user inputed values (Need Help)
    By Zebra in forum New To Java
    Replies: 2
    Last Post: 04-16-2008, 01:51 PM
  4. Random Integers
    By www.kwalski.com in forum Java Applets
    Replies: 8
    Last Post: 12-09-2007, 05:49 PM
  5. Convert roman numerals to integers
    By Felissa in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 11:27 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
  •