java number to word

java number to word

Can somebody please fix this to come out with the word, not the number 23?

import java.util.Scanner;

public class WordExtractor5
{
//-----------------------------------------------------------------
// Pulls integers from a string to form a word.
//-----------------------------------------------------------------
public static void main (String[] args)
{
Scanner scan=new Scanner(System.in);
String strLineOfText;
String word = "";
int character;

System.out.print("Enter a line of text: " );//The cat in the hat 18 characters
strLineOfText = scan.nextLine();

System.out.println(); // blank line

System.out.print("Enter an integer for the starting character " +
"position followed by 5 integers \nspecifying the number of " +
"characters to move from the previous character \nto the next " +
"to extract a 6-character word: " );
character = scan.nextInt()-1;
character += scan.nextInt();
character += scan.nextInt();
character += scan.nextInt();
character += scan.nextInt();
character += scan.nextInt();


System.out.println ();

System.out.print("The word you extracted is:= " + character );

}
}
View Answers

June 30, 2010 at 3:15 PM

Hi Friend,

Try the following code:

import java.util.Scanner;

public class WordExtractor5{
public static void main (String[] args){
Scanner scan=new Scanner(System.in);
String strLineOfText;
String word = "";
int character;

System.out.print("Enter a line of text: " );
strLineOfText = scan.nextLine();

System.out.println();

System.out.print("Enter an integer for the starting character " +
"position followed by 5 integers \nspecifying the number of " +
"characters to move from the previous character \nto the next " +
"to extract a 6-character word: " );
character=scan.nextInt();
word=strLineOfText.substring(character,character+6);
System.out.println ();
System.out.print("The word you extracted is:= " + word );
}
}

Thanks









Related Tutorials/Questions & Answers:
java number to word - Java Beginners
java number to word  Can somebody please fix this to come out with the word, not the number 23? import java.util.Scanner; public class... { //----------------------------------------------------------------- // Pulls integers from a string to form a word
NUMBER OF VOWELS IN A WORD
NUMBER OF VOWELS IN A WORD  WRITE A PROGRAM THAT WILL INPUT A WORD THEN IT WILL DETERMINE THE NUMBER OF VOWELS PRESENT IN THE INPUTTED WORD
Advertisements
from number to word
from number to word  i want to know weather there is any method that can be use in changing value from number to word. Example if i write ten thousand, it will automatically be written as 10000.   Java convert number
Java Word Processor
Java Word Processor  Problem: Design and implement a class called... (see description below) ? return several counts about the text o number of words (a hyphenated word is one word), o number of sentences (ends
convert date month and year into word using java
;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10...; int word; string = ""; while (number != 0
convert date month and year into word using java
;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10...; int word; string = ""; while (number != 0
word program - Java Beginners
method that counts the number of occurrencies of a letter in a word and returns...word program  HELLO MAM AND SIR I ASK YOUR HELP HOPE YOU GONNA HELP ME THANK YOU!!Design a program to search a word for letters that the user
String file in to word file in java
String file in to word file in java  How to convert a String format notepad file into Ms word file in java
Word replacment - Java Beginners
Word replacment  Java code for the Word Replacement.Thnaks in Advance!  Hipublic class WordReplaced{ public static void main(String[] args... information,http://www.roseindia.net/java
String file in to word file in java
String file in to word file in java  how to convert a String format word file into Ms Word file using java? please can anyone of you help me
word and character counting - Java Beginners
word and character counting  here is the java code i made but i have to add something where it will read the inFile and display the number of words and number of characters.. can you help me with it? thanks.. :) import
PDF to Word Conversion - Java Beginners
PDF to Word Conversion  Hello, Can we convert a PDF document to Microsoft word document thru Java. If its not possible in Java, is it possible in any other language
Retrieve a list of words from a website and show a word count plus a specified number of most frequently occurring words
;String,Integer> object where the value is the number of occurrences of the word... int N = 25; //the number of word/frequency pairs to print //word pattern...; Integer count; // number of occurrences WordPair(String word
Java word extraction program. - Java Beginners
Java word extraction program.  Need to code a public class named... an integer for the starting letter position followed by 5 integers specifying the number...- character word. The starting position should be based on the leftmost character
Word Count
Word Count       This example counts the number of occurrences of  a specific word in a string. Here we are counting the occurrences of word "you" in a string
Number Convert - Java Beginners
passString(int number){ int num, q ; if (number < 10 ){ displayOutput(a[number...]) ; } if ( number > 19 ){ num = number % 10 ; if ( num == 0 ){ q = number / 10 ; displayOutput (d[q-2]) ; } else{ q = number / 10 ; displayOutput(a[num
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
java code to open and display MS-word document
java code to open and display MS-word document  java code to open and display MS-word document
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
java word counting - Java Beginners
java word counting  Hi I want a code in java that replaces a word with another when its occurred independently and ignores the case of the text... but this will change all the occurrence even if its part of another word the run
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.  **A program in JAVA which accepts a sentence & displays the longest word in the sentence along
How to format number in Java?
How to format number in Java?  Hi, What is the best way to format a number in Java? How to format number in Java? Thanks   Hi, To format number in Java you can use the class java.text.NumberFormat. Here is simple
Java Word Occurrence Example
Java Word Occurrence Example In this example we will discuss about the how... name from command line which returns the number of occurrences of each word... can count the occurrences of each word in a file. In this example we will use
export to word document - Java Beginners
export to word document  hi sir,when i am click on a button under the jtable,for example (print button),then i want to print that jtable in word document,automatically,plz provide program sir  Hi Friend, Try
create MS Word in Java - Java Beginners
which creates MS Word in Java...create MS Word in Java  Hi, Could any one please post the code which creates the word document having different paragraphs and two tables. i have
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
getting random number in java
getting random number in java  getting random number in java Hi... and scaling the random number in my Java Random number eample. but for some reason... to generate the random number in Java Thanks in Advance
convert date month and year into word using java
Java Date Month Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year Java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Match Date format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Date Format in Jave  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Basic format for Date and Month  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Month format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
number - Java Interview Questions
number  apka number kya hai aap apna number mera id per send ker do
number of stairs - Java Beginners
number of stairs  1. Write a program that prints an n-level stair case made of text. The user should choose the text character and the number...(); } } } ----------------------------------- read for more information, http://www.roseindia.net/java/master
prime number - Java Beginners
prime number  i want to write a code in java that picks prime numbers... boolean isPrime(int number){ boolean isPrime=false; int i=(int) Math.ceil(Math.sqrt(number)); while (i>1
Creating MS Word document in java - Struts
Creating MS Word document in java  I have one template in MS Word which has some content. Now i want to read this doc file and wants to add some... you plz tell me how to do in java
prime number - Java Beginners
prime number  this project is to determine if a phone number is a prime number. if the number is a prime number then print a message to the effect. if the number is not a prime number then print the prime factors of the number
Write a program in Java to convert Decimal number into Binary number
Write a program in Java to convert Decimal number into Binary number  Hi, I have decimal number and I want to convert it to Binary. How to Write a program in Java to convert Decimal number into Binary number? Thanks
add number - Java Beginners
add number  Q. write a programe to add three number. The number input... input=new Scanner(System.in); System.out.println("Enter first number"); int a=input.nextInt(); System.out.println("Enter second number"); int b
program on factorial of a given number in java
program on factorial of a given number in java  please tell me, how to write program on factorial of a given number in java
program on factorial of a given number in java
program on factorial of a given number in java  please tell me, how to write program on factorial of a given number in java
perfect number - Java Beginners
perfect number  An integer number is said to be a perfect number.... For example, 6 is a perfect number because 6 = 1+2+3. Write a method perfect that determines if parameter number is a perfect number. Use this method
Magic number in java
Magic number in java  Hi.. Can any one tel how to watch a magic number of a program?   import java.util.*; class MagicNumber...); System.out.print("Enter the number: "); int num =input.nextInt(); int b=0,x
Convert Number to Roman Number Using Java
Java Convert Number to Roman Numerals In this section, you will learn how to convert the number to roman number.  To do this, we have created a class... and the method convertIntegerToRoman(int n) convert the specified number into roman

Ads