Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help with Assignment work

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with Assignment work

    Hello, this is my second post on the forms but I need some help with something that is just stumping me.

    I have an assignment to complete where I have to develop a Java Console application in Eclipse which accepts regional zone information for premises based upon addresses provided. The program needs to figure out which geographical zone each customer lives in and based upon their age, set a priority rating.

    The zones (which is the Belfast and the directions) and sub-zones (which are the Postcode such as "BT1" are:

    Zones
    BELFAST
    "BT1 ", "BT2 ", "BT3 ", "BT4 ", "BT5 ", "BT6 ", "BT7 ", "BT8 ", "BT9 ", "BT10", "BT11", "BT12", "BT13", "BT14", "BT15"
    NORTH
    "BT39", "BT40", "BT41", "BT42", "BT43", "BT44", "BT45", "BT46", "BT51", "BT52", "BT53", "BT54", "BT55", "BT56", "BT57"
    SOUTH
    "BT25", "BT26", "BT32", "BT35", "BT60", "BT61", "BT62", "BT63", "BT64", "BT65", "BT66", "BT67", "BT68", "BT69", "BT70", "BT71", "BT80"
    EAST
    "BT16", "BT17", "BT18", "BT19", "BT20", "BT21", "BT22", "BT23", "BT24", "BT27", "BT28", "BT29", "BT30", "BT31", "BT33", "BT34", "BT36", "BT37", "BT38"
    WEST
    "BT47", "BT48", "BT49", "BT74", "BT75", "BT76", "BT77", "BT78", "BT79", "BT81", "BT82", "BT92", "BT93", "BT94"
    UNALLOCATED
    No Postcode provided


    What I specifically need to do is
    1. Display a count of addresses within a user defined geographical zone.
    2. Display all information for customers within a user defined geographical zone.
    3. Display a complete set of captured data.
    4. Display a prioritized list of customer details within each geographical zone.
    5. Display a count of customers within each geographical zone.

    Below is the code I have created so far for it.

    package assignment1;
     
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
     
    public class Assignment1 {
     
    	private static InputStreamReader input = new InputStreamReader(System.in);
    	private static BufferedReader reader = new BufferedReader(input);
     
    	// Variables
    		static int intRecordCount = 0;
    		static int intColumnCount = 0;
     
    		//2D arrays to hold a) record count(row)      b) 6 pieces of info (column)
    		static String[][] aryCustomers = new String[1][6];
     
    	/**
    	 * @param args
    	 */
    		//Main Method
    	public static void main(String[] args)
    	{
    	    MainMenu();
    	}
     
    	// Display user menu.
    	private static void MainMenu()
    	{
     
    	//Variables
    		int intMenuChoice = 0;
    		do
    		{
    			try
    			{
    				//Display Menu
    				//this will display the menu allowing the user to select a number between 1 and 5 to continue
     
    				System.out.println("=====================================================================================");
    				System.out.println("========   Main Menu   ==============================================================");
    				System.out.println(" 1. Add new customer information    ");
    				System.out.println(" 2. Display a count of addresses within a user defined geographical zone             ");
    				System.out.println(" 3. Display all information for customers within a user defined geographical zone    ");
    				System.out.println(" 4. Display a complete set of captured data                                          ");
    				System.out.println(" 5. Display a prioritised list of customer details within each geographical zone     ");
    				System.out.println(" 6. Display a count of customers within each geographical zone                       ");
    				System.out.println(" 7. Exit program                                                                     ");
    				System.out.println("=====================================================================================");
     
    				//this is to accept the menu choice
    				System.out.print("Enter Option :   ");
    				intMenuChoice = Integer.parseInt(reader.readLine());
     
    					//Selection based on option choice
    					if ( intMenuChoice == 1)
    					{
    						System.out.println("Can now accept Customer Information");
    						AcceptInformation();
    					}
    					else if ( intMenuChoice ==2)
    					{
    						System.out.println("Will now display a count of addresses within a user defined geographical zone ");
    						AddressCount();
    					}
    					else if ( intMenuChoice ==3)
    					{
    						System.out.println("Will now display all information for customers within a user defined geographical zone");
    						AreaCustomer ();
    					}
    					else if ( intMenuChoice ==4)
    					{
    						System.out.println("Will now display Complete Set of All Data");
    						DisplayAllCustomers();
    					}
    					else if ( intMenuChoice ==5)
    					{
    						System.out.println("Will now display a prioritised list of customer details within each geographical zone");
    						CustomerPriority();
    					}
    					else if ( intMenuChoice ==6);
    					{
    						System.out.println("Will now display a count of customers within each geographical zone");
    						AreaCount();
    					}
    					else if ( intMenuChoice ==7);
    					{
    						System.out.println("Goodbye ! ");
    					}
     
    					// this will display a message to show the menu choice entered
    					// is not between 1 and 7
     
    					else
    					{
    						System.out.print("Invalid Menu Selection");
    					}
     
     
    				}
    					catch(Exception ex) 
    				{
    					System.out.println ("Error : " + ex.getMessage());
    				}
    			} while (intMenuChoice != 7 );
     
     
    	}
    	// Menu choice 1. Add new customer information.
    		private static void AcceptInformation() {
    		try
    		{
    			//accept info
    			System.out.print("Record " + (intRecordCount + 1) + " Enter Name : ");
        		StrCustomerName[intRecordCount] = reader.readLine();
     
        		System.out.print("Record " + (intRecordCount + 1) + "Enter Address: ");
                strAddress[intRecordCount] = Integer.parseInt(reader.readLine());
     
                System.out.print("Record " + (intRecordCount + 1) + "Enter Postcode: ");
                strPostcode[intRecordCount] = Integer.parseInt(reader.readLine());
     
                System.out.print("Record " + (intRecordCount + 1) + "Enter Age: ");
                intAge[intRecordCount] = Integer.parseInt(reader.readLine());
     
              //increase counter
                intRecordCount++;
     
    		}
                catch (Exception ex)
                {
                        System.out.println("Error : "+ ex.getMessage());
                }
     
    				// expand array for next customer
     
     
     
     
     
    		}
    		// Menu choice 2. Display the number of addresses within a geographical area
    		// defined by user.
    		private static void AddressCount() 
    		{
    			try
     
    					// Display Menu
    					// this will display the menu allowing the user to select an
    					// Area
    			System.out.print(" Please select the Area in which to find addresses : ");
    			System.out.println(" ---- ");
    			System.out.println(" 1. Belfast ");
    			System.out.println(" 2. North ");
                System.out.println(" 2. South ");
                System.out.println(" 3. East ");
                System.out.println(" 4. West ");
     
     
    					// this is to accept the menu choice
                System.out.print("Enter Area :   ");
    			strArea = Integer.parseInt(reader.readLine());
     
    			System.out.print("There are: ");
     
    					// Selection based on option choice (switch)
    			switch
     
     
    					// this will display a message to show the menu choice entered
    					// is not between 1 and 7
     
    		}
     
     
    		// Menu choice 3. Print all customer details for a user defined geographical
    		// area.
    		private static void AreaCustomer() 
    		{
    			//variables
     
     
    					// Display Menu
    					// this will display the menu allowing the user to select an
    					// Area
    			System.out.print(" Please select the Area in which to find customers : ");
    			System.out.println(" ---- ");
    			System.out.println(" 1. Belfast ");
    			System.out.println(" 2. North ");
                System.out.println(" 2. South ");
                System.out.println(" 3. East ");
                System.out.println(" 4. West ");
     
     
    					// this is to accept the menu choice
                System.out.print("Enter Area :   ");
    			strArea = Integer.parseInt(reader.readLine());
     
    					// Selection based on option choice
     
     
     
     
    					// this will display a message to show the menu choice entered
    					// is not between 1 and 7
     
    		}
     
     
    		// Menu choice 4. Display all Customer details.
    		private static void DisplayAllCustomers() 
    		{
    			 //Variables
     
                int intLoopCounter = 0;
     
                try
                {
     
                	for (intLoopCounter = 0; intLoopCounter < intRecordCount; intLoopCounter++)
                        {
                		System.out.println("Name : " + StrCustomerName[intLoopCounter]);
                		System.out.println("Address : " + StrAddress[intLoopCounter]);
                        System.out.println("Postcode : " + strPostcode[intLoopCounter]);
                        System.out.println("Age: " + intAge[intLoopCounter]);
     
                		 }
     
                		//Increase Counter
                		intRecordCount ++;
     
            }
                catch (Exception ex)
                {
                        System.out.print("Error: " + ex.getMessage());
                }
    		}
     
    		// Menu choice 5. Print out a list of customers sorted by priority within
    		// each geographic area.
    		private static void CustomerPriority() 
    		{
     
    		}
     
    		// Menu choice 6. Display a count off all customers within each geographical
    		// area.
    		private static void AreaCount() 
    		{
     
    		}
     
    		// Calculate customer priority based upon area.
    		private static void CalculateCustomerPriority() 
    		{
     
     
    			// variables
     
    			// First sort customers into their geographic areas.
     
    		}
     
    		// Calculate the geographic zone for each customer.
    		private static void CalculateGeoZone(String PostCode) 
    		{
    			if ( strPostcode == BT1)
    			{
    				strArea = Belfast;
    			}
    			else if ( intMenuChoice ==2)
    			{
    				System.out.println("Will now display a count of addresses within a user defined geographical zone ");
    				AddressCount();
    			}
    			else if ( intMenuChoice ==3)
    			{
    				System.out.println("Will now display all information for customers within a user defined geographical zone");
    				AreaCustomer ();
    			}
    			else if ( intMenuChoice ==4)
    			{
    				System.out.println("Will now display Complete Set of All Data");
    				DisplayAllCustomers();
    			}
    			else if ( intMenuChoice ==5)
    			{
    				System.out.println("Will now display a prioritised list of customer details within each geographical zone");
    				CustomerPriority();
    			}
    			else if ( intMenuChoice ==6);
    			{
    				System.out.println("Will now display a count of customers within each geographical zone");
    				AreaCount();
    			}
    			else if ( intMenuChoice ==7);
    			{
    				System.out.println("Goodbye ! ");
    			}
    		}
     
    		// Sort customers by age.
    		private static void SortCustomers() 
    		{
     
    			Arrays.sort(aryCustomers, new Comparator<String[]>() 
    			{
    				@Override
    				public int compare(String[] entry1, String[] entry2) 
    				{
    					String age1 = entry1[4];
    					String age2 = entry2[4];
    					return age2.compareTo(age1);
    				}
    			});
    		}
     
    		public static String[][] Expand(String[][] array, int size) {
     
    			String[][] temp = new String[size][6];
     
    			int rows = temp.length - 1;
    			int loop = 0;
     
    			while (loop < rows) {
    				temp[loop][0] = (array[loop][0]);
    				temp[loop][1] = (array[loop][1]);
    				temp[loop][2] = (array[loop][2]);
    				temp[loop][3] = (array[loop][3]);
    				temp[loop][4] = (array[loop][4]);
    				temp[loop][5] = (array[loop][5]);
    				loop++;
    			}
     
    			temp[rows][0] = "*";
    			temp[rows][1] = "*";
    			temp[rows][2] = "*";
    			temp[rows][3] = "*";
    			temp[rows][4] = "*";
    			temp[rows][5] = "*";
     
    			return temp;
     
     
     
    	}
     
    }


    Putting it straight out there, I do not want a full blown answer, as that is against site rules and I am not one to cheat in my work. However, the main issue I'm having is to make sure that data like address and customer counts, and customer details appear only for the selected areas. If anyone could lend some input, that would be great.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Help with Assignment work

    This includes the same code you posted earlier when it was framed as an Eclipse problem. It's okay to start a new thread and now focus on fixing the code's functionality, but this code still has the errors you were already told to fix when you first posted the code, plus new errors. Why are you posting buggy code? Why aren't you fixing the errors that should be obvious to you, especially those you've already been told about? If you're not going to 'listen,' take advice, and do as we suggest, then there's really no point in trying to help you.

Similar Threads

  1. Replies: 3
    Last Post: January 26th, 2014, 11:51 PM
  2. how to work wsimport for this WSDL i get errors and i cant make it work
    By pato.llaguno in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 24th, 2014, 05:27 PM
  3. Replies: 5
    Last Post: March 20th, 2013, 02:29 PM
  4. assignment troubles polymorphism (guide for assignment included)
    By tdawg422 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 8th, 2011, 10:01 AM
  5. Replies: 1
    Last Post: February 22nd, 2010, 08:20 AM