/* 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);
}
}
No comments:
Post a Comment
any problem in any program comment:-