The
program is like: take a sentence and display starting characters in each words
in upper case and the rest in lower case. This program is done in two
techniques in BlueJ.
Import java.io.*;
class A
{
 String name,str;
 BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
 int i,j;
 void take () throws Exception
 {
 
System.out.println("Enter any sentence:");
 
name=br.readLine();
 
}
  
void show()
  
{
   
i=1;
   
while(true)
   
{
   
j=name.indexOf(' ');
   
if(j< 0)<0 o:p="o:p">0>
   
break;
 
  str=name.substring(0,j);
   
name=name.substring(j+1);
   
for(i=0;i< str.length();i++)
   
{
    
if(i==0)
     
System.out.print(Character.toUpperCase(str.charAt(i)));
     
else
      
System.out.print(Character.toLowerCase(str.charAt(i)));
   
}
   
System.out.print(" ");
   
}
   
for(i=0;i< name.length();i++)
   
{
    
if(i==0)
     
System.out.print(Character.toUpperCase(name.charAt(i)));
     
else
      
System.out.print(Character.toLowerCase(name.charAt(i)));
   
}
   
}
   
public static void main(String args[])throws Exception
   
{
    
A ob=new A();
    
ob.take();
    
ob.show();
    
}
    
}
The same program is done using a different technique.
import java.io.*;
class A
{
 String name;
 BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
 int i,j,f=0;
 void take () throws Exception
 {
 
System.out.println("Enter any sentence:");
 
name=br.readLine();
 
}
  
void show()
  
{
  
j=name.length();
  
for(i=0;i< j;i++)
  
{
   
if(i==0)
     
System.out.print(Character.toUpperCase(name.charAt(i)));
     
else if(name.charAt(i)==' ')
     
{
      
System.out.print(" "+Character.toUpperCase(name.charAt(i+1)));
      
i++;
      
}
      
else
      
System.out.print(Character.toLowerCase(name.charAt(i)));
     
}
    
}
   
public static void main(String args[])throws Exception
   
{
    
A ob=new A();
    
ob.take();
    
ob.show();
    
}
Sir, can you please upload a specimen paper for java programs likely to come in ISC 2013?
ReplyDeleteAfter Diwali I will upload expected programs for ISC 2013.
Delete