Results 1 to 4 of 4
  1. #1
    Irish Rayray is offline Member
    Join Date
    Apr 2012
    Posts
    21
    Rep Power
    0

    Default Calculating Which Members in a java program have a gold Membership

    Hi all,

    I am doing some basic java programs and have run into a slight problem at the moment and was wondering if anybody can help.

    Java Code:
    public class Main{
    	public static void main(String args[])
    	{
    		Member[] Mem = new Member[5];
    		
    		Mem[0] = new Member(78478, "Alice Martin", true, 3400);
    		Mem[1] = new Member(42535, "Bernard Nolan", false, 2500);
    		Mem[2] = new Member(65464, "Claire Owens", true, 3500);
    		Mem[3] = new Member(67478, "Dave Pearson", true, 3300);
    		Mem[4] = new Member(76964, "Edel Quirke", false, 2200);
    		
    		int TotalMembers = 0;
    		double averageFee = 0;
    	
    		for(int i = 0; i < Mem.length; i++)
    		{
    			if (Mem[i] != null)
    		    {
    				TotalMembers ++;
    		    }
    			averageFee += Mem[i].getFee() ;
    		}
    		averageFee = averageFee/5;
    		
    		System.out.println("Total Number of Members is " + TotalMembers);
    		System.out.println("Total Number of Members with Gold Rating is ");
    		System.out.println("Average Fee for Members with Gold Rating is ");
    		System.out.println("Average Fee payed is " + averageFee);
    		System.out.println("-----------------------------------------------------------------");
    	
    		
    		System.out.println("Alice's new Mebership fee is " + (Mem[0].getFee() + 100));
    		System.out.println("Bernard's new Mebership fee is " + (Mem[1].getFee() + 100));
    		System.out.println("Claire's new Mebership fee is " + (Mem[2].getFee() + 100));
    		System.out.println("Dave's new Mebership fee is " + (Mem[3].getFee() + 100));
    		System.out.println("Edel's new Mebership fee is " + (Mem[4].getFee() + 100));
    		
    		Mem[4].setName("Edel Reynolds");
    		System.out.println("Edel Quirke's name has changed to " + Mem[4].getName());
    		
    	}
    }
    What I'm trying to do is find out the total number of members with gold rating then get the average fee for them.
    I know that i can do the average fee bit but im having trouble geting the total number of gold members bit.

    Any help will be appreciated.
    Last edited by Irish Rayray; 12-04-2012 at 05:46 PM.

  2. #2
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    305
    Rep Power
    6

    Default Re: Calculating Which Members in a java program have a gold Membership

    What have you tried? If you can get the average fee, then you should already have the number of gold members.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Calculating Which Members in a java program have a gold Membership

    OK, pretend you have a stack of cards rather than that array.
    Those cards hold the Member data above.

    How would you do this by hand?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    Irish Rayray is offline Member
    Join Date
    Apr 2012
    Posts
    21
    Rep Power
    0

    Default Re: Calculating Which Members in a java program have a gold Membership

    I dont have the average Fee done for gold Members but i do have it done for overall fee along with a few other little things but i didn't include them as they have nothing to do with this if you wish ill edit it to include them.

Similar Threads

  1. Blackjack Program Not Calculating Totals Correctly
    By skaterboy987 in forum New To Java
    Replies: 1
    Last Post: 10-19-2011, 08:59 PM
  2. calculating time of program runing
    By sara12345 in forum New To Java
    Replies: 3
    Last Post: 03-17-2010, 12:25 AM
  3. Help with calculating triangle program
    By ALH813 in forum New To Java
    Replies: 5
    Last Post: 10-19-2009, 05:08 AM
  4. Replies: 4
    Last Post: 08-12-2008, 01:41 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
  •