Results 1 to 8 of 8
- 12-16-2010, 06:19 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 3
- Rep Power
- 0
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.
- 12-16-2010, 06:21 PM #2
- 12-16-2010, 06:21 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Ok, what you have done so far, can you show us over here?
- 12-16-2010, 06:28 PM #4
Member
- Join Date
- Dec 2010
- Posts
- 3
- Rep Power
- 0
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 06:32 PM. Reason: code tags added
- 12-16-2010, 06:31 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Please use code tags next time. Unformated codes are really hard to read.
- 12-16-2010, 06:34 PM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What you've done here is real mess. Do you know about methods in Java?
- 12-16-2010, 06:39 PM #7
Member
- Join Date
- Dec 2010
- Posts
- 3
- Rep Power
- 0
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 :)
- 12-16-2010, 06:47 PM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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
-
How to solve java.security.AccessControlException
By chyrl in forum Advanced JavaReplies: 0Last Post: 09-24-2010, 08:49 PM -
how to solve this ERROR --java.lang.OutOfMemoryError: Java heap space
By krunalpatel1410 in forum New To JavaReplies: 5Last Post: 08-13-2010, 10:04 AM -
Please solve my java.lang.NullPointerException error.?
By Viruthagiri in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 03-23-2010, 09:30 PM -
Please help me solve these Java Problems
By saculellav in forum New To JavaReplies: 7Last Post: 07-27-2008, 11:58 AM -
A great doubt in Java Applet,will u solve it!!
By anithababu in forum Java AppletsReplies: 6Last Post: 01-27-2008, 01:20 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks