Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners java number to word
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Benjamin
java number to word
1 Answer(s)      4 years and 6 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 );

}
}

Advertisement
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
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 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 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
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
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
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
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
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
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
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 open and display MS-word document
java code to open and display MS-word document  java code to open and display MS-word document
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
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
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
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
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
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
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
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
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
 

 

 

DMCA.com