https://www.codechef.com/FXBG2020/problems/FTB004

https://www.codechef.com/FXBG2020/problems/FTB004
Author:- pj220593
Tester:- pj220593
Editorialist:- pj220593
Difficulty:- easy
PREREQUISITES:- String class
Solution:-
The number should be taken input as the string and then each digit of the string (converted char) should be subtracted with ‘0’ ASCII code. If the number obtained is greater than equal to 5 it should be subtracted from 9 and stored.

import java.util.;
import java.lang.
;
import java.io.*;

class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
try{
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
String ans="";
if(s.charAt(0)==‘9’)
ans=ans+s.charAt(0);
else
{
if((s.charAt(0)-‘0’) >=5)
{
ans=ans+(‘9’-s.charAt(0));
}
else
ans=ans+s.charAt(0);
}
for(int i=1;i<s.length();i++)
{
if((s.charAt(i)-‘0’) >=5)
{
ans=ans+(‘9’-s.charAt(i));
}
else
ans=ans+s.charAt(i);
}
System.out.println(ans);
}catch(Exception e){}
}
}