Activity Stream
48,167 MEMBERS
6879 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19
  1.     
    #11
    Banned
    need help in this output please..

    12345
    22345
    33345
    44445
    55555

  2.   Sponsored Links

  3.     
    #12
    You can call me G
    Code: 
    
    
    /**
     * Prints the pattern in the post above.
     * 
     * @author Gaurav
     * @version 1.0
     */
    public class pattern
    {
        public static void main(String[] args) {
            for(int i = 1; i <= 5; i++){
                for(int j = 1; j <=5; j++){
                    if(j < i){
                        System.out.print(i);
                    }
                    else{
                        System.out.print(j);
                    }
                }
                System.out.println();
            }
        }
    }
    That should do it .

    One suggestion. Please do try doing the programs yourself first.. If you're stuck somewhere then only look out for help. Just typing in the pattern and asking for the solution gives the impression that you want us to do your homework (not saying that this might be the case). But I and many others would appreciate if you post your progress as well along with the question.



    My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz

  4.     
    #13
    Banned
    nope I'm self learning bro, and I really make one for this but the problem is I didn't really think putting if-else in a nested for loop..

  5.     
    #14
    Banned
    any can help me out ive been trying so hard but failed..

    Output:
    54321
    4321
    321
    21
    1

    But using the "while" syntax. not nested for loop. is it possible?

  6.     
    #15
    You can call me G
    Here you go:

    Code: 
    
    
    /**
     * Prints the above mentioned pattern
     * 
     * @author Gaurav <Gaurav@besthostingforums.com>
     * @version 1.0
     */
    public class PatternKWWH
    {
        public void display() {
            int n = 5;        
            while(n >= 1){
                int k = n;
                while(k >= 1){
                    System.out.print(k);
                    k--;
                }
                System.out.println();
                n--;
            }
            
        }
    }



    My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz

  7.     
    #16
    Banned
    ^ Thank you so much gaurav its perfect.. well I have a new problem bro our professor said "Make a nested loop, that will prints out All Even numbers in in 1-50, and when it goes to 51-100 it prints out odd numbers"
    basically when its still 1<50 it will prints out 2,4,6,8..50 and when its 51-100 it prints out 51,53,55,57,59..99..

    Ive tried this so far..
    Code: 
    public class oddeven {
    
        public static void main(String[] args){
        	System.out.println("Even numbers: ");
        	for(int a=1;a<=50;a++){
        		if(a%2 == 0){
        			System.out.println(a);
        		}
        	}
        	System.out.println("Odd numbers: ");
        	for(int a=51;a<=100;a++){
        		if(a%2 == 1){
        			System.out.println(a);
        		}
        	}
        }
    
    
    }
    but our processor says make it into a single loop now I can't do it.. please please help.

  8.     
    #17
    Member
    Website's:
    PasteBot.appspot.com
    ^^
    Make 1 loop, go from 0 to 100.
    In there put an if clause.
    So,

    Code: 
    if a<50:
        if a%2 == 0:
            print a
    else:
        if a%2 == 1:
            print a
    I think you have no idea what you're doing and just wasting time.
    It can't get easier than this, and you're struggling to complete them.
    So do some reading and get your head around this stuff. Start from the basics. Read your textbook and make sure you understand each word. Use a dictionary if English is not your First Language.

  9.     
    #18
    Member
    Website's:
    WarezNeed.com
    System.out.println("Odd numbers: "); for(int a=51;a<=100;a++){ if(a%2 == 1){ System.out.println(a);

    You Getting Wrong Here Make it 0 instead of 1

    Get Your Personal / Corporate Website Starting @ Just Rs. 700/- Per Year
    Freelance Web Solution Plz PM Me --


  10.     
    #19
    You can call me G
    He wants to print odd numbers.. so the remainder after dividing by 2 should be one.. He's correct there..

    Try this:

    Code: 
    /**
     * Prints the above mentioned pattern
     * 
     * @author Gaurav <Gaurav@besthostingforums.com>
     * @version 1.0
     */
    public class oddeven
    {
         public static void main(String[] args){
        	for(int i = 1; i <= 100; i++) {
                if(i <= 50 && i % 2 == 0) {
                    System.out.println(i);
                }
                else if(i > 50 && i % 2 == 1){
                    System.out.println(i);
                }
            }
        }
    }



    My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Java stinks: Turn off your Java browser plugin
    By Loget in forum General Discussion
    Replies: 37
    Last Post: 5th Sep 2012, 07:40 AM
  2. [PHP] Need help to loop true the results
    By AndroidApps in forum Web Development Area
    Replies: 6
    Last Post: 5th Feb 2012, 09:56 AM
  3. Php Loop Prob
    By Chris2k in forum Web Development Area
    Replies: 1
    Last Post: 16th Jan 2012, 02:00 PM
  4. What's the biggest forum out there? Been out of the loop..
    By wildfire95 in forum Webmasters, Money Making
    Replies: 3
    Last Post: 7th May 2011, 11:28 AM
  5. Redirect loop?!?!
    By GeeZus in forum Technical Help Desk Support
    Replies: 4
    Last Post: 9th Jun 2009, 04:36 AM

Tags for this Thread

BE SOCIAL