Questions:
1. Write a Java program to get a number from the user and print whether it is
positive or negative.
2. Take three numbers from the user and print the greatest number.
3. Write a Java program that reads a floating-point number and prints "zero" if the
number is zero. Otherwise, print "positive" or "negative".
Add "small" if the absolute value of the number is less than 1, or "large" if it
exceeds 1,000,000.
4. Write a Java program that takes the user to provide a single character from the
alphabet.
Print Vowel or Consonant, depending on the user input.
If the user input is not a letter (between a and z or A and Z), or is a string of length
> 1, print an error message.
5. Write a program in Java to display n terms of natural numbers and their sum.
6. Write a program in Java to input 5 numbers from keyboard and find their sum
and average.
7. Write a program in Java to display the cube of the number upto given an
integer.
8. Write a program in Java to display the multiplication table of a given integer.
9. Write a program in Java to display the n terms of odd natural number and their
sum.
,10. Write a program in Java to display the pattern like right angle triangle with a
number.
1
12
123
1234
12345
123456
1234567
12345678
123456789
12345678910
11. Write a program in Java to make such a pattern like right angle triangle with a
number which will repeat a number in a row.
The pattern is as follows :
1
22
333
4444
12. Write a program in Java to make such a pattern like right angle triangle with
number increased by 1.The pattern like
,1
23
456
7 8 9 10
13. Write a program in Java to make such a pattern like a pyramid with a number
which will repeat the number in the same row.
1
22
333
4444
14. Write a program in Java to print the Floyd's Triangle.
Input number of rows : 5
1
23
456
7 8 9 10
11 12 13 14 15
, 15. Write a program in Java to display the pattern like a diamond.
Input number of rows (half of the diamond) : 7
Expected Output :
*
***
*****
*******
*********
***********
*************
***********
*********
*******
*****
***
*
16. Write a Java program to display Pascal's triangle.
1. Write a Java program to get a number from the user and print whether it is
positive or negative.
2. Take three numbers from the user and print the greatest number.
3. Write a Java program that reads a floating-point number and prints "zero" if the
number is zero. Otherwise, print "positive" or "negative".
Add "small" if the absolute value of the number is less than 1, or "large" if it
exceeds 1,000,000.
4. Write a Java program that takes the user to provide a single character from the
alphabet.
Print Vowel or Consonant, depending on the user input.
If the user input is not a letter (between a and z or A and Z), or is a string of length
> 1, print an error message.
5. Write a program in Java to display n terms of natural numbers and their sum.
6. Write a program in Java to input 5 numbers from keyboard and find their sum
and average.
7. Write a program in Java to display the cube of the number upto given an
integer.
8. Write a program in Java to display the multiplication table of a given integer.
9. Write a program in Java to display the n terms of odd natural number and their
sum.
,10. Write a program in Java to display the pattern like right angle triangle with a
number.
1
12
123
1234
12345
123456
1234567
12345678
123456789
12345678910
11. Write a program in Java to make such a pattern like right angle triangle with a
number which will repeat a number in a row.
The pattern is as follows :
1
22
333
4444
12. Write a program in Java to make such a pattern like right angle triangle with
number increased by 1.The pattern like
,1
23
456
7 8 9 10
13. Write a program in Java to make such a pattern like a pyramid with a number
which will repeat the number in the same row.
1
22
333
4444
14. Write a program in Java to print the Floyd's Triangle.
Input number of rows : 5
1
23
456
7 8 9 10
11 12 13 14 15
, 15. Write a program in Java to display the pattern like a diamond.
Input number of rows (half of the diamond) : 7
Expected Output :
*
***
*****
*******
*********
***********
*************
***********
*********
*******
*****
***
*
16. Write a Java program to display Pascal's triangle.