Home Answers Viewqa Java-Beginners java number to word

 
 


Benjamin
java number to word
1 Answer(s)      2 years and 11 months ago
Posted in : Java Beginners

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 Pages:
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 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
Word Count
Word Count       This example counts the number of occurrences of  a specific word...\kodejava>java WordCountExample 3 occurrences of the word 'you' in 'How r you?R you
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
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
Count instances of each word
Count instances of each word  I am working on a Java Project that reads a text file from the command line and outputs an alphabetical listing... number 1 of 1 program 2 test 2 that 1 the 1 this 1 to 1 total 1 using 1 verify 1
convert date month and year into word using java
; int word; string = ""; while (number != 0...: word = number % 100; pass(word); if (number > 100 && number % 100
convert date month and year into word using java
; int word; string = ""; while (number != 0...: word = number % 100; pass(word); if (number > 100 && number % 100
Example - Replace word
Java: Example - Replace word Problem: Write a method to replaces all occurences a word in a string with another word. Assume the method signature... a new String. The word "replace" is probably misleading. Also, the method
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
Java Word Count - Word Count Example in Java
Java Word Count - Word Count Example in Java  ... to count the number of lines, number of words and number of characters in the specified file. Program takes the file name as parameter and it counts the number
Number Convert - Java Beginners
(); System.out.println("Number to word: "+num.convertNumber(10)+"."); System.out.println("Number to word :"+num.convertNumber(15)+"."); System.out.println("Number to word :"+num.convertNumber(50)+"."); System.out.println("Number to word :"+num.convertNumber
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
Java Count word occurrence and export it to excel file
Java Count word occurrence and export it to excel file Here is an example of scanning a text file in a local drive, and count the frequency of each word in the text file or you can say count the number or occurrence of each word
Compare two word file
Compare two word file  How to compare two word file using 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
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link will provide an example that will read the document file using POI library in java
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link will provide an example that will read the document file using POI library in java
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link will provide an example that will read the document file using POI library in java
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
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
finout longest word in sentence
finout longest word in sentence  write a program , how to find out the longest word in a sentence using java   Hi Friend, Try...; } } LongestWord(){ String word = ""; for(int i=0;i<stringArray.length;i++){ if(i==0
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
Scanning a word in a TEXT document......
by searching the JAVA and .net words present in the files..if JAVA word is present means...Scanning a word in a TEXT document......  Hi Genius persons... I'm having many resumes in my FOLDER called HARISH in D:(colon) i want to scan
Scanning a word in a TEXT document......
by searching the JAVA and .net words present in the files..if JAVA word is present means...Scanning a word in a TEXT document......  Hi Genius persons... I'm having many resumes in my FOLDER called HARISH in D:(colon) i want to scan
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
Count number of occurences and print names alphabetically in Java
Count number of occurences and print names alphabetically in Java  I... for the printCount() method for the code to count the number of occurences of each word and print in alphabetical order to produce this output: {bob=1, jim=1, tim=1
store form data into word document
store form data into word document  i want form page data, ex username phone number.. to store it in a word document file
convert word document to pdf
convert word document to pdf  Hi, Could you please help me write a java code that converts the word docuemnt into PDF? I have to save the generated... a java beginner. Please help out in this. Thanks in advance. Regards, Sindhu
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
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
prime number
prime number  get one number and check the number prime or not using if statement   Java Check Prime Number
prime number
prime number  check prime number using if statement   Java Check Prime Number
prime number
prime number  check prime number using if statement   Java Check Prime Number
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
prime number
prime number  HI!I want a java program that accepts a number from user and displays whether it is a prime number or not using BufferedReader
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
prime number
prime number  To check a number entered by user is prime or not?   Java check prime number import java.util.*; class CheckPrimeNumber { static boolean isPrime(int number){ boolean isPrime=false
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
Collections Exercise 4 - Word Translator
Java: Collections Exercise 4 - Word Translator 333. leftnewads2.shtml...: An online dictionary is needed. The user will enter a word and the program... of definitions, which give the different possible translations of a word. For example
how to translate english word to marathi using java
how to translate english word to marathi using java  I want to translat english word to marathi,how i can develop a code for that ,please sajest me
Java Convert Number to Words
Java Convert Number to Words In this section, you will learn how to convert...", "ninty" }; public String convert(int number) { int n = 1; int word; string = ""; while (number != 0) { switch (n) { case 1: word
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
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.