APP Week - 5 Assignment Abiram
APP Week - 5 Assignment Abiram
PRACTICE
ASSIGNMENT-5
RA2211026010486
G.Abiram
Z2-cse Aiml
PROGRAMS:
Ans:
import java.util.Scanner;
sc.close();
}
Output:
Enter a string: Hello
Mirror Image: olleH
Ans:
Output:
import java.util.ArrayList;
import java.util.List;
printEvenNumbers(numbers);
}
Output:
Original list: [1, 2, 3, 4, 5, 6]
Even numbers: 2 4 6
Ans:
import java.util.Scanner;
checkPalindrome(input);
sc.close();
}
if (original.equalsIgnoreCase(reversed)) {
System.out.println("The string '" + str + "' is a palindrome.");
} else {
System.out.println("The string '" + str + "' is not a
palindrome.");
}
}
}
Output:
Ans:
import java.util.Scanner;
if (isPrime) {
System.out.println(number + " is a prime number.");
} else {
System.out.println(number + " is not a prime number.");
}
sc.close();
}
if (num <= 3) {
return true;
}
if (num % 2 == 0 || num % 3 == 0) {
return false;
}
return true;
}
}
Output:
Enter a number: 17
17 is a prime number.
6.Write a Java program to find the digits which are absent in a given
mobile number (using function) ?
Ans:
import java.util.Scanner;
public class MissingDigitsInMobileNumber {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a mobile number: ");
String mobileNumber = sc.nextLine();
if (missingDigits.isEmpty()) {
System.out.println("All digits are present in the mobile
number.");
} else {
System.out.println("Missing digits in the mobile number: " +
missingDigits);
}
sc.close();
}
return missingDigits.toString();
}
}
Output:
7.Write a Java program using function that will return true if the two
given integer values are equal or their sum or difference is 5.
Ans:
import java.util.Scanner;
if (result) {
System.out.println("The two integers meet the condition.");
} else {
System.out.println("The two integers do not meet the
condition.");
}
sc.close();
}
Output:
Ans:
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
System.out.println("Character counts:");
for (Map.Entry<Character, Integer> entry :
charCount.entrySet()) {
System.out.println("'" + entry.getKey() + "': " +
entry.getValue());
}
sc.close();
}
public static Map<Character, Integer> countCharacters(String
text) {
Map<Character, Integer> charCount = new HashMap<>();
return charCount;
}
}
Output:
Ans:
generateCombinations();
}
Output:
Ans:
import java.util.HashSet;
import java.util.Set;
return uniqueValues.size();
}
}
Output: