English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have tried to solve this program but am unsuccessful at it. Can anybody please solve this one for me or atleast tell me how to go about it????

Here is the program Q:
Read a line of text(i.e accept a sentence from the user) containing uppercase,lowercase and special characters.Print text with uppercase and lowercase letters reversed but all other characters intact.

Eg:
INPUT:"The Sun is settiNG"
OUTPUT:"tHE sUN IS SETTIng"

2007-02-24 18:09:20 · 2 answers · asked by kri91-16 2 in Computers & Internet Programming & Design

2 answers

hi.....i am a java programmer it a easy program just take the strinf from user and add 32 to each letter......remember u will need type casting for it......so so it will be done

i hope it will help....

2007-02-24 18:19:56 · answer #1 · answered by Puneet Sharma 3 · 0 0

first u have to input the string and then substitute the uppercase character by lower case character and vice versa.
here is the program

// !! RAM !!

import java.io.BufferedReader;
import java.io.*;

public class converter
{
public static void main( String[] a )
{
try{
BufferedReader d = new BufferedReader( new InputStreamReader(System.in ));

String input;
System.out.println( " enter string " );
input = d.readLine();
String output="";

for( int i=0;i< input.length();i++)

{
if( Character.isLowerCase( input.charAt(i) ) )
output += Character.toUpperCase( input.charAt(i) );
else
output += Character.toLowerCase( input.charAt(i) );
}
input = output;
System.out.println( " ur string is::"+ input );
}
catch( IOException e)
{
System.out.println(" IOException throwed ");
}
}
}

2007-02-24 19:03:53 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers