Computer Science, asked by pratham0609, 1 year ago

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
4

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);

}

Answered by laxmipriyabhargava
0

Here your answer...

Hope it hlps...

Mark as Branliest.....

Attachments:
Similar questions