Jump to content




Recent Topics

Recent Status Updates

  • Photo
      15 Nov
    duzamucha

    Hi, I am final year Interior Design Student from University of Huddersfield. I am currently working on my final major project which is going to be linked to coding. I was hoping that you could help me with my research. I have prepared a short survey, it would be a massive help if you could fill it in for me. It takes less than 2 minutes to complete, I promise. Here is the link: https://www.surveymonkey.com/s/73XLJKK Thank you so much in advance!

View All Updates

Developed by TechBiz Xccelerator
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
  • 242 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   110 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.

I can believe, but why should I?





Powered by binpress