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 = 165
Difference = 35
Answers
Answered by
3
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
Biology,
6 months ago
Chemistry,
6 months ago
Social Sciences,
6 months ago
English,
1 year ago
Math,
1 year ago