Jump to content





Recent Status Updates

  • Photo
      10 Apr
    Poe

    Finally (and hopefully) i'm getting a team together that knows a little of this and a little of that; and maybe all my open source projects that are half written can begin to be released. :)

View All Updates
Photo
- - - - -

Java Newbie Challenge

java loop java exercises

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 Harold

Harold

    CC Regular

  • Member
  • PipPipPip
  • 27 posts

Posted 05 March 2013 - 10:26 PM

  Hello!

 

I'll take this as a challenge for all newbie in java. This is only for those who are interested. After you take this challenge you are now at your first step in becoming a java expert. These exercise can help developing your mind in making strategic plans, brain teasing and brain storming.

 

Ok. I'll have 2 challenge for you.

 

1. Write a program that prompts the user to enter a number(1-10 only) and display it as a pyramid shape.

     Hint : 

              Enter a number(1-10): 7 //for example the user input 7

                    

              The program will output this way: Pyramid Shape

                                      1

                                  2  1  2

                              3  2  1  2  3

                          4  3  2  1  2  3  4

                      5  4  3  2  1  2  3  4  5

                 6   5  4  3  2  1  2  3  4  5  6

             7  6   5  4  3  2  1  2  3  4  5  6  7

 

2. Using the nested loop write a program that prints the following: A BINARY PYRAMID

                                      

                                       1

                                  1   2    1

                              1  2   4   2   1

                          1  2  4   8   4  2  1

                      1  2  4  8  16  8  4  2  1

                  1  2  4  8 16 32 16 8  4  2 1

             1  2  4  8 16 32 64 32 16 8 4 2 1

         1 2  4  8 16 32 64 128 64 32 16 8 4 2 1

 

If you attempt to answer and getting the corrent program to these kindly post so that I can check whether your program is good to go.


Edited by harold212011, 05 March 2013 - 10:27 PM.


#2 Ritwik I the programmer

Ritwik I the programmer

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 202 posts

Posted 06 March 2013 - 12:06 AM

In addition, if someone feels they are quite adept at tackling logical and algorithmic problems in programming, they can try the problems attached. (Post the soln. in this thread if you solve any, there are 38 problems in the attached file:

Attached File  INOI_Problems.doc   266KB   79 downloads

 

Note:

The original document was quite filled with printing mistakes. If you still find anything amiss, post it.


Edited by Ritwik I the programmer, 06 March 2013 - 10:05 AM.

1.Make it simple 2.Make it simple 3.Make it simple 4.make it simple 5. ............