0

any time a number is present in a word inflate its value by 1........
for eg, input anyone up four tennis
output anytwo up five elevennis

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by monarchmk
0

First build an array of numbers...

String [] numbers=new String[13];
	numbers[0]="zero";
	numbers[1]="one";
	....
	....
	....

After array read input line from whatever device you need...
and declare one more string to handle new text like this...

String text=keyb.readLine();
	String newtext=text;

now make a loop thought all of array

for (int i=0;i<numbers.length;i++) {}

and here are some conditions involved..

if (text.contains(numbers[i]))
{
	newtext=newtext.replace(numbers[i],numbers[i+1]);
}

Rest is System.out.println,... for printing newtext

If this solved your problem, please mark thread SOLVED, if not i'll be glad to answer any of your question about this solution

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.