Results 1 to 8 of 8
  1. #1
    Rachel_B is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Smile How to i solve this java senario??

    I am trying to teach myself java at the moment so i would love to know how to complete this scenario in java....i am trying to use eclipse!? thanks! x


    The production department of a local manufacturer would like to produce statistics, including histograms, for the productivity of its manufacturing staff in 2008 and 2009. The company is involved in the manufacture of utility vehicles for the construction industry. Staff work in shift teams comprised of 20 employees.

    Write a program to read the amount of items produced by each shift team for the two years, generate a histogram for each year and the statistics. The details are given below:

    For each year calculate
    o The average amount of items produced;
    o The shift team in each year with the highest amount of items produced and the amount; and
    o The shift team in each year with the lowest amount of items produced and the amount.

    Over the two years
    o The average amount of goods produced for each shift team

    Your program should include the following methods:-

     A method readStats () which takes an array of integers as a parameter to hold the amount produced by each shift team for one year. It should read the quantities of items produced from the keyboard into the array.

     A method calculateandDisplayStats() which takes an array of integers holding the amount produced by each shift team for one year and displays the statistics for that year. This method should call other value methods:
     one to return the average amount produced for the year
     one to return the position in the array of the shift team with the highest productivity
     one to return the position in the array of the shift team with the lowest productivity.

     A method yearlyStats() which will take two arrays of integers representing the amount produced for each year and display the average amount produced for each shift team.

     A method printChart() which takes an array of integers as a parameter holding the amount produced by each shift team for one year and prints a histogram for that year.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

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

  4. #4
    Rachel_B is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default

    This is where i have got so far up until the average but i am struggling to get a grasp on the arrays...!?

    Java Code:
    // Name: Rachel Bell
    // Date:22/12/2010
    /* The program shown below is designed to calculate the
     * average amount of items produced and find the shift team
     * with the lowest and highest amount of products produced
     */
    import java.util.Scanner; // import input utility
    public class Trial {
    	
    	public static void main (String[]args){ //start the main method
    		
    		System.out.println("*******************************");
    		System.out.println("   \tNumbers Program		   ");
    		System.out.println("*******************************");
    		
    		Scanner numbers = new Scanner (System.in);
    		
    		System.out.print ("Please enter the amount of shift teams for each year");
    		final int amount = numbers.nextInt();
    		
    		int[] year_1= new int[amount]; // initialising array
    		int[] year_2= new int[amount];
    		
    		year_1 = readStats(year_1);
    		System.out.println("We will now look at the second year");
    		year_2 = readStats(year_2);
    		System.out.println("All values have now been entered");
    		calculateandDisplayStatsYear1(amount,year_1);
    		calculateandDisplayStatsYear2(amount,year_2);
    	
    		static int[] readStats (int[]year)
    	{
    		Scanner numbers = new Scanner (System.in);
    		for( int i=0; i<year.length; i++)
    		{
    			System.out.print("Enter the amount produced by shift team "+(i+1));
    			year[i] = numbers.nextInt();
    		}
    		return year;
    
    	}
    		static void calculateandDisplayStats1 (int [] amount, int year, int [] total)
    		
    		
    		void calculateandDisplayStatsYear1(int [] amount, int year_1){
    		System.out.println("****************************************************");
    		System.out.println("display the average amount of items produced " + year_1);
    		
    		
    		
    		System.out.println("*****************************************************");
    		System.out.println("display the highest amount of items produced " + year + "is" + );
    		
    		System.out.println("***************************************************");
    		System.out.println("display the lowest amount of items produced " + year + "is" + );
    		
    		}
    		
    		static double calculateandDisplayStatsYear11(int [] amount, int year_1){
    		double total=0;
    		for( int i=0; i<amount.length; i++);
    		return total;
    		}
    
    		static double calculateandDisplayStatsYear2(int [] amount, int year_2){
    		double total=0;
    		for( int i=0; i<amount.length; i++);
    		return total;
    		}
    }
    Last edited by Eranga; 12-16-2010 at 07:32 PM. Reason: code tags added

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

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

  7. #7
    Rachel_B is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default

    I know i am trying to teach myself how to do java at the moment...:( i have a rough idea about methods but i am only at a beginner level, just trying to figure out how i would go about completing this scenario and then learn from that!?

    Even if i could get the average done then it might give me a better insight into how to layout your program etc.

    Many Thanks :)

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

    Default

    Okay then.

    Actually my first advice is you yo study about more methods in Java.

    Second point is never implement a large process in a single method. Basic idea about methods is that the functionality (or the process) you want to implement is more specific as well as a smaller one. And also don't write everything in main method.

    As a startup, and since you are newbie to Java, cold you step-down your requirement and show it here. Then I'll help you to complete one step at a time.

Similar Threads

  1. Please help me solve these Java Problems
    By saculellav in forum New To Java
    Replies: 9
    Last Post: 07-06-2014, 10:25 AM
  2. How to solve java.security.AccessControlException
    By chyrl in forum Advanced Java
    Replies: 0
    Last Post: 09-24-2010, 09:49 PM
  3. Replies: 5
    Last Post: 08-13-2010, 11:04 AM
  4. Please solve my java.lang.NullPointerException error.?
    By Viruthagiri in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-23-2010, 10:30 PM
  5. A great doubt in Java Applet,will u solve it!!
    By anithababu in forum Java Applets
    Replies: 6
    Last Post: 01-27-2008, 02:20 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
  •