Question: Java Programs
Program 1: Find Maximum of 2 nos.
Program 2: Find Minimum of 2 nos. using conditional operator
Program 3: Write a program that will read a float type value from the keyboard and print the following output.
->Small Integer not less than the number.
->Given Number.
->Largest Integer not greater than the number.
Program 4: Write a program to generate 5 Random nos. between 1 to 100, and it should not follow with decimal point.
Program 5: Write a program to display a greet message according to Marks obtained by student.
Program 6: Write a program to find SUM AND PRODUCT of a given Digit.
Program 7: Write a program to Find Factorial of Given no.
Program 8: Write a program to Reverse a given no.
Program 9: Write a program to find Fibonacci series of a given no.
Example: Input - 8
Output - 1 1 2 3 5 8 13 21
Program 10
Write a program to find sum of all integers greater than 100 and less than 200 that are divisible by 7
Program 11: Write a program to Concatenate string using for Loop
Example: Input - 5
Output - 1 2 3 4 5
Program 12: Program to Display Multiplication Table
Program 13: Write a program to Swap the values
Program 14: Write a program to convert given no. of days into months and days. (Assume that each month is of 30 days)
Example: Input - 69
Output - 69 days = 2 Month and 9 days
Program 15: Write a program to generate a Triangle. eg:
1
2 2
3 3 3
4 4 4 4 and so on as per user given number
Program 16: Write a program to Display Invert Triangle.
Example: Input - 5
Output :
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
Program 17: Write a program to find whether given no. is Armstrong or not.
Example: Input - 153
Output - 1^3 + 5^3 + 3^3 = 153, so it is Armstrong no.
Program 18: Write a program to Find whether number is Prime or Not.
Program 19: Write a program to find whether no. is palindrome or not.
Example: Input - 12521 is a palindrome no.
Input - 12345 is not a palindrome no.
Program 20: Write a program to generate a below out put.
Example: Input - 5
Output :
5 5 5 5 5 5 5 5 5
4 4 4 4 4 4 4
3 3 3 3 3
2 2 2
1
Program 21: Write a program to generate a below out put.
Example: Input - 3
Output :
1
2 2 2
3 3 3 3 3
Program 22: Write a program to generate a below out put.
Example: Input - 5
Output :
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
Program 23: Write a program to generate a below out put.
Example: Input - 3
Output :
1
1 2 1
1 2 3 2 1
1 2 1
1
Program 24: Switch case demo
Example: Input - 124
Output - One Two Four
Program 25: Write a program to generate Harmonic Series.
Example: Input - 5
Output - 1 + 1/2 + 1/3 + 1/4 + 1/5 = 2.28 (Approximately)
Program 26
Write a program to find average of consecutive N Odd no. and Even no.
Program 27: Display Triangle as follow: BREAK DEMO.
1
2 3
4 5 6
7 8 9 10 ... N
Program 28: Display Triangle as follow
0
1 0
1 0 1
0 1 0 1
Program 29: Display Triangle as follow
1
2 4
3 6 9
4 8 12 16 ... N (indicates no. of Rows)
Program 30: Write a program to convert given Decimal number to Binary, Octal and Hexa decimal number and display all the values.
Example:
Input - 17
Output -
Binary - 10001
Octal - 21
Decimal - 17
Hexa Decimal - 11