Java Code To Create Pyramid and Pattern
Example 1: Program to print half pyramid using * * * * * * * * * * * * * * * * Source code public class Main {…
Example 1: Program to print half pyramid using * * * * * * * * * * * * * * * * Source code public class Main {…
Example: Program to Sort Strings in Dictionary Order public class Sort { public static void main(String[] args) { String[] words = { "Ruby", "C", "Python", "Java" }; for(int i =…
Example: Represent a number as Sum of Two Prime Numbers public class Main { public static void main(String[] args) { int number = 34; boolean flag = false; for (int…
Example: Simple Calculator using switch Statement import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner reader = new Scanner(System.in); System.out.print("Enter two numbers: "); // nextDouble() reads…
Example 1: Factors of a Positive Integer public class Main { public static void main(String[] args) { // positive number int number = 60; System.out.print("Factors of " + number +…
A positive integer is called an Armstrong number of order n if abcd... = an + bn + cn + dn + ... In case of an Armstrong number of 3 digits,…
A positive integer is called an Armstrong number of order n if abcd... = an + bn + cn + dn + ... In case of an Armstrong number of 3 digits,…
Example: Display Prime Numbers Between two Intervals public class Prime { public static void main(String[] args) { int low = 20, high = 50; while (low < high) { boolean…
Example 1: Program to Check Prime Number using a for loop public class Main { public static void main(String[] args) { int num = 29; boolean flag = false; for…
Example 1: Program to Check Palindrome using while loop public class Palindrome { public static void main(String[] args) { int num = 121, reversedInteger = 0, remainder, originalInteger; originalInteger =…