Afaq Ahmad Khan

Reversed Case of Char Array Program in Java

Define a class to accept a string, and print the characters with the uppercase and lowercase reversed, but all the other characters should remain the same as before [10] EXAMPLE: INPUT: WelCoMe_2022 OUTPUT: wELcOmE_2022 import java.util.Scanner; public class ReversedCase { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String st; String newSt […]

Product and Square of Array Program in Java

Define a class to declare an array of size twenty of double datatype, accept the elements into the array and perform the following: • Calculate and print the product of all the elements. • Print the square of each element of the array. import java.util.Scanner; public class ProductOfArray { public static void main(String[] args) { […]

Find Highest and Lowest ASCII value Program in Java

Define a class to declare a character array of size ten, accept the characters into the array and display the characters with highest and lowest ASCII (American Standard Code for Information Interchange) value. [10] EXAMPLE INPUT ‘R’, ‘2’,’9′,’A’,’N’,’p’,’m’, ‘Q’,’F’ OUTPUT: Character with highest ASCII value = z Character with lowest ASCII value =A import java.util.Scanner; […]

Bubble Sort in String Program in Java

import java.util.Scanner; public class BubbleSortString { public static void main(String[] args) { String temp; String str[] = new String[10]; Scanner sc = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.print("Enter the string ar[" + i + "]:"); str[i] = sc.nextLine(); } for (int j = 0; j < str.length; j++) […]

Palindrome String

import java.util.Scanner; public class PalindromeString { public static void main(String[] args) { String st,revSt=””; int l; Scanner sc=new Scanner(System.in); System.out.print(“Enter String:”); st=sc.nextLine(); l=st.length(); for (int i = l-1; i >= 0; i–) { char ch; ch=st.charAt(i); revSt=revSt+ch; } if(st.equals(revSt)) { System.out.println(“Palindrome String”); } else { System.out.println(“Not Palindrome String”); } } } Output: Enter String:asdsa Palindrome […]

Piglatin Form Program in Java

Piglatin Form First, the vowels are checked and first occurring vowel in the word is found. Then, the Piglatin word is formed by taking the substring from first vowel position and then concatinating it with the letters from first letter till the first vowel i.e. before the first vowel.Finally a string “AY” is added at […]

Find Vowels And Capital Letter in Array Program in Java

import java.util.Scanner; public class FindVowelAndCapitalInArray { public static void main(String[] args) { int vowelCount=0, upperCaseCount = 0; char ar[] = new char[10]; Scanner sc = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.print("Enter the number ar[" + i + "]:"); ar[i] = sc.next().charAt(0); } System.out.println("-------------------------------"); for (int i = 0; […]

1 2 3 4 35