This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class StringAnagram { | |
public static void main(String[] args) { | |
String originalWord = "stressed"; | |
String anagramToCheck = "desserts"; | |
System.out.println("First word: " + originalWord); | |
System.out.println("Second word: " + anagramToCheck); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class PyramidPattern { | |
public static void main(String[] args) { | |
int height = getHeightFromUser(); | |
System.out.println("Pyramid pattern of star in Java : "); | |
drawPyramidPattern(height); | |
System.out.println("\nPyramid of numbers in Java : "); | |
drawPyramidOfNumbers(height); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class IntegerPalindrome { | |
public static void main(String[] args) { | |
int numberToCheck = readNumberFromUser(); | |
if (isPalindrome(numberToCheck)) { | |
System.out.println(numberToCheck + " is a palindrome"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class ReverseNumber { | |
public static void main(String[] args) { | |
int originalNumber = getNumberFromUser(); | |
System.out.println("Original number: " + originalNumber ); | |
int reversedNumber = reverse(originalNumber); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ArmstrongNumber { | |
public static void main(String[] args) { | |
int range = 10000; | |
printArmstrongNumbers(range); | |
} | |
private static void printArmstrongNumbers(int range) { | |
for (int number = 0; number <= range; number++) { | |
if (isArmstrongNumber(number)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class SortArray { | |
static Scanner scanner = new Scanner(System.in); | |
public static void main(String[] args) { | |
int[] array = createArray(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Factorial { | |
public static void main(String[] args) { | |
int numberToCalculate = getInputFromUser(); | |
int result1 = calculateFactorialUsingWhileLoop(numberToCalculate); | |
int result2 = calculateFactorialUsingForLoop(numberToCalculate); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringModifier { | |
public static void main(String[] args) { | |
StringModifier stringModifier = new StringModifier(); | |
stringModifier.reverseWordsInString("Spring Framework"); | |
stringModifier.reverseWordsInString("Java Enterprise Edition"); | |
} | |
private void reverseWordsInString(String stringToModify) { | |
String[] singleStringsArray = stringToModify.split(" "); | |
System.out.println(stringToModify); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Main { | |
static Scanner scanner = new Scanner(System.in); | |
public static void main(String[] args) { | |
int[] arrayToReverse = createArray(); | |
System.out.println("Original array"); | |
printArrayValues(arrayToReverse); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Palindrome { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
System.out.println("Enter the String for check:"); | |
String stringToCheck = scanner.nextLine(); | |
scanner.close(); | |
if (isPalindrome(stringToCheck)) | |
System.out.println(stringToCheck + " is a palindrome"); |
NewerOlder