Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with program to process statements

Status
Not open for further replies.

Yoshimi

Programmer
Nov 25, 2001
1
US
I need to process a sentence and input and letter which will have to be counted at end how many times its used and needed to show what kind of sentence and show shortest word and longest and how many short mid and long words there are sorry thats its alot to ask.

import java.util.StringTokenizer;

public class prog4
{
//-----------------------------------------------------------------
// Processes number of characters shortest word longest word etc.
//
//-----------------------------------------------------------------
public static void main (String[] args)

{
//Initialize Declare
InputStreamReader isr = new InputStreamReader(system.in);
BufferedReader br = new BufferedReader(isr);


final int char = 27;
int 1 = statement.length();
int oneWord
int currentchar, letter, statement, longest, shortest, letter;
double ShortWords, MediumWords, LongWords;
int length();


//Input Data


System.out.println ("Enter a Letter:");
letter=br.readLine();


System.out.println ("Enter a statement:");
statement=br.readLine();

if (statement.charAT(statement.length()-1)==".")
System.out.println ("A sentence");

Else;

if (statement.charAT(statement.length()-1)=="!")
System.out.println ("A Exclamation");

Else;

if (statement.charAT(statement.length()-1)=="?")
System.out.println ("A Question");



StringTokenizer st = new StringTokenizer(statement);
oneWord=st.nextToken();

if (oneWord.length()<shortest.length());

oneWord=st.nextToken();
String shortest = new String(oneWord);


String longest = new String(oneWord);

if(!st.hasMoreTokens());
oneWord=oneWord.substring(0,oneWord.length()-1);

if (oneWord.length()<=4)
ShortWords++;
System.out.println (&quot;Number of short word: &quot; (ShortWords));

if (oneWord.length()<=7);
MediumWords++;
System.out.println (&quot;Number of medium word: &quot; (MediumWords));

if (oneWord.length()>7);
LongWords++;
System.out.println (&quot;Number of long word: &quot; (LongWords));

 
so whats the problem? u have the code, but there seems to b a lot of bugs. do u get error, if yes what is the error? some prominent errors r

statement.charAT(statement.length()-1)==&quot;.&quot;

should b changed to

statement.charAt(statement.length()-1)=='.'

etc.

luv
Karthik.
LOL A ship is safe in the harbour, but that's not what it is meant for!!! LOL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top