Consider the following statement:
"26 January is celebrated as the Republic Day of India"
Write a program (using scanner class) to change 26 to 15; January to August; Republic to Independence and finally print as:
"15 August is celebrated as the Independence Day of India"
ICSE 2006
BEST EASY SOLUTION
USING REPLACE METHOD
import java.util.*;
class Icse2006
{
void main()
{
Scanner ob=new Scanner(System.in);
String s,s1="";
s="January 26 is celebrated as the Republic Day of India";
s1=s.replace('2','1');
s1=s1.replace('6','5');
s1=s1.replace("January","August");
s1=s1.replace("Republic","Independence");
System.out.println("INPUT:="+s);
System.out.println("DESIRED OUTPUT="+s1);
}
}