Decoding In Java ISC CBSE Class 12
import java.util.*;
class Decode{
public static void main(){
Scanner sc=new Scanner(System.in);
String str,s="";
int i,l,j,ss,r,sr=0;
System.out.println("Enter a sentence");
str=sc.nextLine();
l=str.length();
for(j=0;j<l;j++){
if((str.charAt(j)>=65&&str.charAt(j)<=90)||(str.charAt(j)>=97&&str.charAt(j)<=122)||(str.charAt(j)==32)){
s=s+(int)str.charAt(j);
}//if
}//for j
ss=Integer.parseInt(s);
while(ss>0){
for(i=0;i<=ss;i++){
r=ss%10;
ss/=10;
sr=sr*10+r;
}//i
System.out.println("Reverse Decoded Message "+sr);
}//while
}//End of main
}//End of class
class Decode{
public static void main(){
Scanner sc=new Scanner(System.in);
String str,s="";
int i,l,j,ss,r,sr=0;
System.out.println("Enter a sentence");
str=sc.nextLine();
l=str.length();
for(j=0;j<l;j++){
if((str.charAt(j)>=65&&str.charAt(j)<=90)||(str.charAt(j)>=97&&str.charAt(j)<=122)||(str.charAt(j)==32)){
s=s+(int)str.charAt(j);
}//if
}//for j
ss=Integer.parseInt(s);
while(ss>0){
for(i=0;i<=ss;i++){
r=ss%10;
ss/=10;
sr=sr*10+r;
}//i
System.out.println("Reverse Decoded Message "+sr);
}//while
}//End of main
}//End of class
Comments
Post a Comment