Results 1 to 15 of 15
  1. #1
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default looping and filtering

    hi guys, this is my 2nd time to post codes to ask ideas/suggestions from you.. ;)

    this is my project at this time. i am having another simulation study regarding electric consumption of an internet shop. this is my simulation problem which i will trying to simulate.

    * i will going to determine the electric consumption of each computer which the internet cafe have 15 computers.
    i have my equation to compute the cost of electric consumption.

    Watts x Hours Used
    .............1000.................x Cost per kilowatt-hour = Total Cost

    where: watt = random between 65-250 watts
    hours Used = random between 5 - 900mins which 900 is equavalent to 15hrs because internet cafe operate only 15hrs a day.
    cost per kwh = 3.92 (fixed)


    MY PROBLEM now are:
    1. How to loop the random values of watts and hours simultaneously of 15 computers?


    sample table:

    PC no. 1
    __________________________
    |Time used (hrs) | Watt Used |
    __________________________
    ..........4................|........130 |
    ..........1................|........218 |
    ..........3................|........121 |
    ..........2................|........135 |
    ..........1................|........224 |
    ..........3................|........99 |
    ..........1................|........234 |
    ______________|___________|

    sample equation:

    PC1x1 = (((130 * 4) / 1000) * 3.92) = 2.03
    PC1x2 = (((218 * 1) / 1000) * 3.92) = .85
    PC1x3 = (((121 * 3) / 1000) * 3.92) = 1.42


    2. How to codes summation in java? i attached my equation..:) I am having trouble of coding my algorithm on my equation..

    3. How to filter the hours if it is exceed 15hrs?

    here is my code initial code where i am having trouble of looping and filtering. that will be my

    Java Code:
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.border.*;
    import java.util.Random;
    import java.util.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.text.*;
    
    
    
    
    public class ICS
    {
    	public static void main (String args[])
    	{
    		
    		
    		int tu;
    		double wattrate = 3.92;
    		
    
    		
    		
    		
    		for (int x=0; x<=5; x++){
    		
    		 Random tur = new Random();  
    		 	int turmin = 5;
    		 	int turmax = 900;
    		 	tu = tur.nextInt (turmax-turmin+1)+ turmin;
    
    
                double tt = tu / 60;
                System.out.println("Time used: " + tt);
      
             	 	Random war = new Random();
             	 	
             	 	int min = 65;
          	 		int max = 250;
            		int wa = war.nextInt(max-min+1)+min;
    			
    				int wax = wa;
    				
    				
    				double totalwat = (wax * tt) / 1000;
    				double totalcost = totalwat * wattrate;
    				
    				
    				DecimalFormat ttcost = new DecimalFormat ("#.##");
    				
    				
    				System.out.println("Watt used by PC 1: " +wax);
    				System.out.println("Total KWh used:" + totalwat);
    				System.out.println("Total KWh cost: $" + ttcost.format(totalcost)  + " in " + tt + "hour(s)" + "\n");
    				
    
             	 }
             
             
             
             
    
    		
    		System.exit(0);
    
    
    		
    		}
    	
    }

    PS: for comments, questions, suggestion, please free to ask and post.. . learning is getting more ideas from other. listening suggestions for improving one self..:)
    Attached Files Attached Files

  2. #2
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default

    can i use switch instead for loop???

  3. #3
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default

    switch is not effective...:( any suggestion pls...:(

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Have you learned to create classes yet? If so, I would create a Computer class to represent each computer, and store its time and watt consumption in the object. I would then create an array of these Computer objects and loop through my array updating the objects with the data as I go.

    I would use a java.util.Random object for randomization. To get a random number between x and y, you'd do something like random.nextInt(y - x + 1) + x
    Java Code:
    public static final int MAX_HOURS = ....; // fill in the ...!!
    public static final int MIN_HOURS = ....;
    java.util.Random random = new java.util.Random();
    
    //..... in the body of the code
    int hours = random.nextInt(MAX_HOURS - MIN_HOURS + 1) + MIN_HOURS;

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by javafanatic View Post
    can i use switch instead for loop???
    I can't think of any situation where this would be appropriate as a switch is simply not a loop.

    2. How to codes summation in java? i attached my equation.. I am having trouble of coding my algorithm on my equation..
    Summation is nothing more than addition. Often you'll use a summation variable and add to it using the += operation. For e.g.,

    Java Code:
    int sum = 0;
    for (....) { // your for loop
      sum += myIntArray[i]
    }


    3. How to filter the hours if it is exceed 15hrs?
    Simply set up your random number generator to not go beyond 15 hrs. My suggestion in my post above hopefully should help you.
    Last edited by Fubarable; 12-12-2009 at 05:01 PM.

  6. #6
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default

    Thanks Fubarable...:D i will try your suggestions... :D

  7. #7
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default

    Seasons Greetings to all of you guyz... It's Christmas time and its a break. so i will take a break of coding my project for now.. Please don't delete my thread and will update you soon after the break.. . .:):)

  8. #8
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default

    hi... im back... and the long days of rest, i ended up an improvement... :)



    Java Code:
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.border.*;
    import java.util.Random;
    import java.util.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.text.*;
    
    
    
    
    public class ICS
    {
    	public static void main (String args[])
    	{
    		
    		
    	
    		double wattrate = 3.92;
    		
    		double TotalC;
    		
    		double totalPC1c;
    		double totalPC1c1;
    		double totalPC1c2;
    		double totalPC1c3;
    		
    		double PC1TIMEused;
    		double PC1TIMEused1;
    		double PC1TIMEused2;
    		double PC1TIMEused3;
    		
    		
    		double totalPC2c1;
    		double totalPC2c2;
    		double totalPC2c3;
    		double totalPC2c;
    		
    		
    		double PC2TIMEused;
    		double PC2TIMEused1;
    		double PC2TIMEused2;
    		double PC2TIMEused3;
    		
    		
    		
    
    			
    	//		for (int i=0; i<=15; i++){
    				
    			
    			Random time = new Random();  
    		 	double turmin = 5;
    		 	double turmax = 180;
    		 	double PC1r1 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               	double PC1t1 = PC1r1 / 60;
               	            
             	 	Random watt = new Random();
             	 	
             	 	int min = 65;
          	 		int max = 250;
            		int PC1w1 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx1 = PC1w1;
    				
    				
    				double PC1tw1 = (PC1wx1 * PC1t1) / 1000;
    				double PC1tc1 = PC1tw1 * wattrate;
    							
    			/////
    				double PC1r2 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC1t2 = PC1r2 / 60;
               	            
            		int PC1w2 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx2 = PC1w2;
    				
    				
    				double PC1tw2 = (PC1wx2 * PC1t2) / 1000;
    				double PC1tc2 =PC1tw2 * wattrate;
    				
    			///
    				double PC1r3 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC1t3 = PC1r3 / 60;
               	            
            		int PC1w3 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx3 = PC1w3;
    				
    				
    				double PC1tw3 = (PC1wx3 * PC1t3) / 1000;
    				double PC1tc3 =PC1tw3 * wattrate;
    				
    			///			
    				double PC1r4 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC1t4 = PC1r4 / 60;
               	            
            		int PC1w4 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx4 = PC1w4;
    				
    				
    				double PC1tw4 = (PC1wx4 * PC1t4) / 1000;
    				double PC1tc4 = PC1tw4 * wattrate;
    			
    			///
    				double PC1r5 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC1t5 = PC1r5 / 60;
               	            
            		int PC1w5 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx5 = PC1w5;
    				
    				
    				double PC1tw5 = (PC1wx5 * PC1t5) / 1000;
    				double PC1tc5 = PC1tw5 * wattrate;
    				
    			///
    				double PC1r6 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC1t6 = PC1r6 / 60;
               	            
            		int PC1w6 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx6 = PC1w6;
    				
    				
    				double PC1tw6 = (PC1wx6 * PC1t6) / 1000;
    				double PC1tc6 = PC1tw6 * wattrate;
    				
    			///
    				double PC1r7 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC1t7 = PC1r7 / 60;
               	            
            		int PC1w7 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx7 = PC1w7;
    				
    				
    				double PC1tw7 = (PC1wx7 * PC1t7) / 1000;
    				double PC1tc7 = PC1tw7 * wattrate;
    				
    			///
    				double PC1r8 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC1t8 = PC1r8 / 60;
               	            
            		int PC1w8 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx8 = PC1w8;
    				
    				
    				double PC1tw8 = (PC1wx8 * PC1t8) / 1000;
    				double PC1tc8 = PC1tw8 * wattrate;
    				
    			///
    				double PC1r9 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC1t9 = PC1r6 / 60;
               	            
            		int PC1w9 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx9 = PC1w9;
    				
    				
    				double PC1tw9 = (PC1wx9 * PC1t9) / 1000;
    				double PC1tc9 = PC1tw9 * wattrate;
    				
    			///
    				double PC1r10 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC1t10 = PC1r10 / 60;
               	            
            		int PC1w10 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx10 = PC1w10;
    				
    				
    				double PC1tw10 = (PC1wx10 * PC1t10) / 1000;
    				double PC1tc10 = PC1tw10 * wattrate;
    				
    			///
    				double PC1r11 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC1t11 = PC1r11 / 60;
               	            
            		int PC1w11 = watt.nextInt(max-min+1)+min;
    			
    				int PC1wx11 = PC1w11;
    				
    				
    				double PC1tw11 = (PC1wx11 * PC1t11) / 1000;
    				double PC1tc11 = PC1tw11 * wattrate;
    				
    				totalPC1c = PC1tc1 + PC1tc2 + PC1tc3 + PC1tc4 + PC1tc5 + PC1tc6 + PC1tc7 + PC1tc8 + PC1tc9 + PC1tc10 + PC1tc11;
    				PC1TIMEused = PC1t1 + PC1t2 + PC1t3 + PC1t4 + PC1t5 + PC1t6 + PC1t7 + PC1t8 + PC1t9 + PC1t10 + PC1t11;
    				System.out.println("PC1 total watt consumption is: " + totalPC1c +"$");
    				System.out.println("PC1 total time used: " + PC1TIMEused +"hours\n");
    				
    			
    
    				
    				
    				
    				
    ///////////////////////////////start for PC 2 //////////////////////////////
    
    	
    		 		double PC2r1 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t1 = PC2r1 / 60;
    
            		int PC2w1 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx1 = PC2w1;
    				
    				
    				double PC2tw1 = (PC2wx1 * PC2t1) / 1000;
    				double PC2tc1 = PC2tw1 * wattrate;
    							
    			/////
    				double PC2r2 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t2 = PC2r2 / 60;
               	            
            		int PC2w2 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx2 = PC2w2;
    				
    				
    				double PC2tw2 = (PC2wx2 * PC2t2) / 1000;
    				double PC2tc2 =PC2tw2 * wattrate;
    				
    			///
    				double PC2r3 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t3 = PC2r3 / 60;
               	            
            		int PC2w3 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx3 = PC2w3;
    				
    				
    				double PC2tw3 = (PC2wx3 * PC2t3) / 1000;
    				double PC2tc3 =PC2tw3 * wattrate;
    				
    			///			
    				double PC2r4 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t4 = PC2r4 / 60;
               	            
            		int PC2w4 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx4 = PC2w4;
    				
    				
    				double PC2tw4 = (PC2wx4 * PC2t4) / 1000;
    				double PC2tc4 = PC2tw4 * wattrate;
    			
    			///
    				double PC2r5 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t5 = PC2r5 / 60;
               	            
            		int PC2w5 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx5 = PC2w5;
    				
    				
    				double PC2tw5 = (PC2wx5 * PC2t5) / 1000;
    				double PC2tc5 = PC2tw5 * wattrate;
    				
    			///
    				double PC2r6 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t6 = PC1r6 / 60;
               	            
            		int PC2w6 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx6 = PC2w6;
    				
    				
    				double PC2tw6 = (PC2wx6 * PC2t6) / 1000;
    				double PC2tc6 = PC2tw6 * wattrate;
    				
    			///
    				double PC2r7 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t7 = PC2r7 / 60;
               	            
            		int PC2w7 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx7 = PC2w7;
    				
    				
    				double PC2tw7 = (PC2wx7 * PC2t7) / 1000;
    				double PC2tc7 = PC2tw7 * wattrate;
    				
    			///
    				double PC2r8 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t8 = PC2r8 / 60;
               	            
            		int PC2w8 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx8 = PC2w8;
    				
    				
    				double PC2tw8 = (PC2wx8 * PC1t8) / 1000;
    				double PC2tc8 = PC2tw8 * wattrate;
    				
    			///
    				double PC2r9 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t9 = PC2r6 / 60;
               	            
            		int PC2w9 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx9 = PC2w9;
    				
    				
    				double PC2tw9 = (PC2wx9 * PC2t9) / 1000;
    				double PC2tc9 = PC2tw9 * wattrate;
    				
    			///
    				double PC2r10 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t10 = PC2r10 / 60;
               	            
            		int PC2w10 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx10 = PC2w10;
    				
    				
    				double PC2tw10 = (PC2wx10 * PC2t10) / 1000;
    				double PC2tc10 = PC2tw10 * wattrate;
    				
    			///
    				double PC2r11 = time.nextDouble() * (turmax-turmin+1)+ turmin;
               		double PC2t11 = PC2r11 / 60;
               	            
            		int PC2w11 = watt.nextInt(max-min+1)+min;
    			
    				int PC2wx11 = PC2w11;
    				
    				
    				double PC2tw11 = (PC2wx11 * PC2t11) / 1000;
    				double PC2tc11 = PC2tw11 * wattrate;
    				
    				totalPC2c = PC2tc1 + PC2tc2 + PC2tc3 + PC2tc4 + PC2tc5 + PC2tc6 + PC2tc7 + PC2tc8 + PC2tc9 + PC2tc10 + PC2tc11;
    				PC2TIMEused = PC2t1 + PC2t2 + PC2t3 + PC2t4 + PC2t5 + PC2t6 + PC2t7 + PC2t8 + PC2t9 + PC2t10 + PC2t11;
    				System.out.println("PC2 total watt consumption is: " + totalPC2c +"$");
    				System.out.println("PC2 total time used: " + PC2TIMEused +"hours\n");
    				
    				System.out.println("START OF FILTERING BELOW (FOR STUDY PURPOSES ONLY)\n\n\n");
    
    				
    			
    				
    				
    /////////////////START OF FILTERING////////////////////////////////////////////
    		
    	
    		
    	/////////PC 1 FILTERING (The time MUST not go beyond 15 hours)///////////////			
    				
    				if (PC1TIMEused > 15.0)
    				{
    				totalPC1c1 = PC1tc1 + PC1tc2 + PC1tc3 + PC1tc4 + PC1tc5 + PC1tc6 + PC1tc7 + PC1tc8 + PC1tc9 + PC1tc10;
    				PC1TIMEused1 = PC1t1 + PC1t2 + PC1t3 + PC1t4 + PC1t5 + PC1t6 + PC1t7 + PC1t8 + PC1t9 + PC1t10;
    				System.out.println("PC1 total watt consumption is1: " + totalPC1c1 +"$");
    				System.out.println("PC1 total time used1: " + PC1TIMEused1 +"hours\n");
    				
    					if (PC1TIMEused1 > 15.0)
    					{
    					totalPC1c2 = PC1tc1 + PC1tc2 + PC1tc3 + PC1tc4 + PC1tc5 + PC1tc6 + PC1tc7 + PC1tc8 + PC1tc9;
    					PC1TIMEused2 = PC1t1 + PC1t2 + PC1t3 + PC1t4 + PC1t5 + PC1t6 + PC1t7 + PC1t8 + PC1t9;
    					System.out.println("PC1 total watt consumption is1: " + totalPC1c2 +"$");
    					System.out.println("PC1 total time used1: " + PC1TIMEused2 +"hours\n");
    				
    						if (PC1TIMEused2 > 15.0)
    						{
    						totalPC1c3 = PC1tc1 + PC1tc2 + PC1tc3 + PC1tc4 + PC1tc5 + PC1tc6 + PC1tc7 + PC1tc8;
    						PC1TIMEused3 = PC1t1 + PC1t2 + PC1t3 + PC1t4 + PC1t5 + PC1t6 + PC1t7 + PC1t8;
    						System.out.println("PC1 total watt consumption is1: " + totalPC1c3 +"$");
    						System.out.println("PC1 total time used1: " + PC1TIMEused3 +"hours\n");
    				
    						}
    					}
    				
    				}
    				
    		
    				
    	///////////PC 2 FILTERING (The time MUST not go beyond 15 hours)//////////////
    				
    				if (PC2TIMEused > 15.0)
    				{
    				totalPC2c1 = PC2tc1 + PC2tc2 + PC2tc3 + PC2tc4 + PC2tc5 + PC2tc6 + PC2tc7 + PC2tc8 + PC2tc9 + PC2tc10;
    				PC2TIMEused1 = PC2t1 + PC2t2 + PC2t3 + PC2t4 + PC2t5 + PC2t6 + PC2t7 + PC2t8 + PC2t9 + PC2t10;
    				
    				System.out.println("PC2 total watt consumption is1: " + totalPC2c1 +"$");
    				System.out.println("PC2 total time used1: " + PC2TIMEused1 +"hours\n");
    				
    					if (PC2TIMEused1 > 15.0)
    					{
    					totalPC2c2 = PC2tc1 + PC2tc2 + PC2tc3 + PC2tc4 + PC2tc5 + PC2tc6 + PC2tc7 + PC2tc8 + PC2tc9;
    					PC2TIMEused2 = PC2t1 + PC2t2 + PC2t3 + PC2t4 + PC2t5 + PC2t6 + PC2t7 + PC2t8 + PC2t9;
    					System.out.println("PC2 total watt consumption is1: " + totalPC2c2 +"$");
    					System.out.println("PC2 total time used1: " + PC2TIMEused2 +"hours\n");
    				
    						if (PC2TIMEused2 > 15.0)
    						{
    						totalPC2c3 = PC2tc1 + PC2tc2 + PC2tc3 + PC2tc4 + PC2tc5 + PC2tc6 + PC2tc7 + PC2tc8;
    						PC2TIMEused3 = PC2t1 + PC2t2 + PC2t3 + PC2t4 + PC2t5 + PC2t6 + PC2t7 + PC2t8;
    						System.out.println("PC2 total watt consumption is1: " + totalPC2c3 +"$");
    						System.out.println("PC2 total time used1: " + PC2TIMEused3 +"hours\n");
    				
    						}
    					}
    				
    				}	
    				
    					
    					
    	/*				
    			if (PC1TIMEused < 15.0)
    			{
    				if (PC2TIMEused < 15.0)
    				{
    				TotalC = totalPC1c + totalPC2c;
    				System.out.println("TOTAL INTERNET CONSUMPTION: " + TotalC +"$");
    	
    				}
    			}
    			
    			if (PC1TIMEused1 < 15.0)
    			{
    				if (PC2TIMEused2 < 15.0)
    				{
    				TotalC = totalPC1c1 + totalPC2c1;
    				System.out.println("TOTAL INTERNET CONSUMPTION: " + TotalC +"$");
    	
    				}
    			}
    			
    		
    	*/	
    			
    							
    
    			
    	//		}
    					
    				
    			System.exit(0);	
    			
    				
    
        }
             
    }


    I just need a little more help with you guyz... but i can't explain it in an easy way... I just want to add the totalPC1c + totalPC2c if the time is < 15... i made a little filtering on the codes on if statement until it will find the total consumption which the time is <15... i just outputed the filtering so that i can study the output (to observed the difference)... if you don't understand my question, please free to reply and ask questions... maybe through your questions, i can express it to you more clearly... :)


    i qouted it because there was an error on the 2nd if
    Java Code:
    if (PC1TIMEused < 15.0)
    			{
    				if (PC2TIMEused < 15.0)
    				{
    				TotalC = totalPC1c + totalPC2c;
    				System.out.println("TOTAL INTERNET CONSUMPTION: " + TotalC +"$");
    	
    				}
    			}
    			
    			if (PC1TIMEused1 < 15.0)
    			{
    				if (PC2TIMEused1 < 15.0)
    				{
    				TotalC = totalPC1c1 + totalPC2c1;
    				System.out.println("TOTAL INTERNET CONSUMPTION: " + TotalC +"$");
    	
    				}
    			}
    Last edited by javafanatic; 01-18-2010 at 04:09 PM.

  9. #9
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default

    bump... :)

  10. #10
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Split your code into smaller methods each with a well defined purpose and easy to test on its own. Dumping all your logic in the main method will create the debug headaches that you are experiencing now.

  11. #11
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default

    your right, r035198x... but it is getting worst when i will used for loop... :( :( can someone help me convert it to for loop??? i used for loop at first but my algorithm and logic cannot be accomplish... also doing loop, i can't get the summation of each time whether it is >= 15 or <= 15... :( :(

  12. #12
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default

    bumping... ahehehe... :)

  13. #13
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default

    bumping again... :)

  14. #14
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Hopefully in the time that has elapsed, you've worked on your problem some on your own and changed your code some including splitting it up into smaller more manageable classes and methods (per the recs above) allowing us to focus on a smaller bit of code, right?

    If so, you may wish to post the improved code and summary of what your current problem(s) is(are).

  15. #15
    javafanatic is offline Member
    Join Date
    Nov 2009
    Posts
    22
    Rep Power
    0

    Default

    hi everyone... . i am being hopeless... i been trying converting my codes into an array and for loop... :( may i ask a little help from you guyz??? :(

Similar Threads

  1. Filtering data in a JSF dataTable
    By Iori Yagami in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 03-17-2010, 11:17 PM
  2. Noise Reduction by fuzzy image filtering
    By priya deshpande in forum Java Software
    Replies: 0
    Last Post: 10-23-2009, 07:34 AM
  3. Deleting files after filtering the extensions
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-25-2008, 07:00 PM
  4. filtering data in jsf
    By bbq in forum JavaServer Faces (JSF)
    Replies: 2
    Last Post: 07-04-2007, 08:52 AM
  5. Jsf, Filtering Data In A Table
    By Freddie in forum JavaServer Faces (JSF)
    Replies: 2
    Last Post: 05-11-2007, 12:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •