Showing posts with label Java Questions with Answer. Show all posts
Showing posts with label Java Questions with Answer. Show all posts

Java Questions : 1

Problem I You are provided with a series of numbers as the input. You have to print a series of characters containing x and o depending on the value of each number. For each odd number, the printed pattern must end with an x. For even numbers, the pattern should end with an o. An empty line should be printed for the number zero.

Write a program to print a pattern looking at the examples given below.

All numbers will be integers (whole numbers) between 0 and 100. Sample Input The program would be run using command line parameters as shown below.

*Java:-** * java yourprogram 2 3 5 6 1

The output is shown below as it is accepted by the system.
*

xo
xox
xoxox
xoxoxo
x

*Sample Input 2 The program would be run using commandline parameters asshown below.

*Java:-** * java yourprogram 5 10 6 4 2 9
The output is shown below as it is accepted by the system.

*

xoxox
xoxoxoxoxo
xoxoxo
xoxo
xo
xoxoxoxox

*