ICSE 2022 SEM-2 QUESTION 3 SOLVED

 /* 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 value.

 * Example: Input:

 * 'R', 'z', 'q', 'A', 'N', 'p', 'm', 'U', 'Q', 'F'

 * Output:

 * Character with highest ASCII value = z

 * Character with lowest ASCII value = A

 */

import java.util.*;

class QUESTION_3

{

    public static void main(String[]args)

    {

        Scanner sc=new Scanner(System.in);

        char ch[]=new char[10];

        int max=0,min=0;

        System.out.println("Enter ten characters:");

        for(int i=0;i<10;i++)

        {

            ch[i]=sc.next().charAt(0);

        }

        min=ch[0];

        for(int i=0;i<10;i++)

        {

            if(ch[i]<min)

            min=ch[i];

            if(ch[i]>max)

            max=ch[i];

        }

        System.out.println("Character with highest ASCII value = "+(char)max);

        System.out.println("Character with lowest ASCII value = "+(char)min);

    }

}

Second largest number in java using ternary operator

 //Largest second number using ternary operator public class Main { public static void main(String[] args) { int a=5,b=6,c=7; int ...