answersLogoWhite

0

import java.io.*;

class CatToDog

{

protected byte words(String xs)

{

byte a=0;

for(byte i=0;i<xs.length();i++)

{

if(xs.charAt(i)==' ')

a++;

}

return (byte)(a+1);

}

protected static void main()throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

CatToDog o=new CatToDog();

System.out.print("Enter the String: ");

String s=in.readLine();

byte a=o.words(s),b=0,c=0;

String w[]=new String[a];

for(;b<a;b++)

w[b]="";

for(b=0;b<s.length();b++)

{

if(s.charAt(b)==' ')

c++;

else

w[c]+=s.charAt(b);

}

for(b=0;b<a;b++)

{

if(w[b].equalsIgnoreCase("Cat"))

System.out.print("Dog ");

else

System.out.print(w[b]+" ");

}

}}

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Write a c program using string concept enter a sting and replace the new string in to old string and find no of occurrence?

print c co com comp compu


How do you write a vbscript for converting alphanumeric to numeric?

num = InputBox("Enter a number: ","PROGRAM: Square") sumSquare = CInt(num) * CInt(num) MsgBox("The square of " &amp; num &amp; " = " &amp; sumSquare) ===== *NOTE*: The function CInt() is what we use to convert a text string to become a numeric integer value.


Write a program to input a string in the form of name and swap the initials of the namefor example enter a string is rohit Kumar sharma and should be printed RK Sharma?

Get the string from user , then U Split the string with space and put in a string array .Then Find Length of string array , Take first letter of each element in array, Except last. Assigned those to a string, then Fetch Last element of an array, Add it With that String.That's it.


How do we write a program to print your name age address using read data statement in QBASIC?

In QBASIC, you can use the INPUT statement to read data for your name, age, and address. Here's a simple program example: DIM name AS STRING DIM age AS INTEGER DIM address AS STRING INPUT &quot;Enter your name: &quot;, name INPUT &quot;Enter your age: &quot;, age INPUT &quot;Enter your address: &quot;, address PRINT &quot;Name: &quot;; name PRINT &quot;Age: &quot;; age PRINT &quot;Address: &quot;; address This program prompts the user to enter their name, age, and address, then prints the collected information.


Write c program to enter a string it has to display with space?

#include #include using std::cin;using std::cout;using std::endl;using std::string;using std::getline;int main(){string myStr = "";cout

Related Questions

Write a c program using string concept enter a sting and replace the new string in to old string and find no of occurrence?

print c co com comp compu


Write a program that converts a string from small letters to capital letters and vice versa?

Here's a Python program that accomplishes this: def convert_case(input_str): return input_str.swapcase() user_input = input(&quot;Enter a string: &quot;) converted_str = convert_case(user_input) print(&quot;Converted string:&quot;, converted_str)


How do you write a vbscript for converting alphanumeric to numeric?

num = InputBox("Enter a number: ","PROGRAM: Square") sumSquare = CInt(num) * CInt(num) MsgBox("The square of " &amp; num &amp; " = " &amp; sumSquare) ===== *NOTE*: The function CInt() is what we use to convert a text string to become a numeric integer value.


How do you enter integer in python?

In Python, you can enter an integer using the input() function, which captures user input as a string. To convert this string to an integer, you can use the int() function. For example: user_input = input(&quot;Enter an integer: &quot;) integer_value = int(user_input) This will convert the input string to an integer, assuming the user enters a valid integer.


Write a c plus plus program to read a line from keyboard?

#include &lt;iostream&gt; #include &lt;string&gt; int main() { std::string myStr = ""; std::cout &lt;&lt; std::endl &lt;&lt; "Enter a string: "; std::cin &gt;&gt; myStr; system("PAUSE"); return 0; }


How do you display a text reversely in C language without using onlu simply input and output?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { char string[20]; int i=0; printf("Enter the string.\n"); while(i&lt;=19) { scanf("%c",&amp;string[i]); i++; } while(i&gt;=0) { printf("%c",string[i]); i--; } getch(); } In this program it is compulsory to enter 20 characters. Now we can write a program in which it is not necessary. #include&lt;stdio.h&gt; #include&lt;conio.h&gt; #include&lt;string.h&gt; void main() { char string[20]; int length; printf("enter the string.\n"); gets(string); length=strlen(string); length--; while(length&gt;0) { printf("%c",string[length]); length--; } getch(); }


Write a program in php that asks the user to enter a distance in kilometers, then convert that distance to miles. The conversion formula is as follows: Miles = Kilometers x 0,6214?

answer:


How to write a Shell program to find the no of vowels in a text?

clear echo -n "Enter the Name / String:" while : do read name echo $name | awk '{print gsub(/[aeiou]/,"")}' done


When can you enter robot wars?

Write to the program's producers at the BBC.


Write a c program to count the number of word in a string?

#include&lt;stdio.h&gt; void main() { int cnt=0,i; char str[100]; printf("Enter the string "); scanf("%s",str); for(i=0;i&lt;strlen(str)-1;i++) { if(str[i]==' ') cnt++; } printf("\nTotal no. of word in string = %d",cnt); }


Write a program that finds greater of two strings entered by user?

public class StringLength { public static void main(String args[]) { String firstString; String secondString; System.out.println("Please enter string (group of characters) "); firstString=sc.nextString(); System.out.println("Please enter second string (group of characters) "); secondString=sc.nextString(); if(firstString&gt;secondString) { System.out.println(); //create blank line System.out.println("First String is greater than the second string"); System.out.println(); } else { System.out.println("Second string is greater than the first string"); System.out.println(); } }//closes the main method }//closes the class.


Write a program to input a string in the form of name and swap the initials of the namefor example enter a string is rohit Kumar sharma and should be printed RK Sharma?

Get the string from user , then U Split the string with space and put in a string array .Then Find Length of string array , Take first letter of each element in array, Except last. Assigned those to a string, then Fetch Last element of an array, Add it With that String.That's it.