Computer Science, asked by pratham0609, 1 year ago

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 TheShadowVader
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