1) Write a program to accept two different characters and display the sum and difference of their ASCII values Sample Input - A d Sample output - sum of ASCII = 165Difference = 35
Answers
Answered by
0
Answer:
import java.util.*;
Class -A
{
Scanner sc = new Scanner (System.in);
System.out.println (" Enter Two Characters");
char val1= sc.next Char ();
char val2= sc.next Char ();
int a = (int) val1;
int b =(int) val2;
int sum = a+b;
int diff = a-b;
System.out.println ("Sum = "+sum);
System.out.println ("Difference = "+diff);
}
Similar questions