Trying to make a class to read in strings, help needed

hello
i have this class that reads in numbers here is the code
import java.io.*;
public class readNumber {
     public static int readlnt()
          throws java.io.IOException
          BufferedReader str= new BufferedReader(new InputStreamReader(System.in));
          String input;
          int res = 0;
          Integer num = new Integer(res);//create integer object
          input = str.readLine();//read input and return a string
          return num.parseInt(input);//convert String to an int and return
          }// end of read method
     }//end of class numberi was trying to makr one to read in words i have this so far
import java.io.*;
public class readWord {
     public static int readlnt()
          throws java.io.IOException
          BufferedReader str= new BufferedReader(new InputStreamReader(System.in));
          String input;
          String res = null;
          String word = new String(res);
          input = str.readLine();
          return word.parseword(input);
          }// end of read method
     }//end of class numberi need a little help with the readWord class, any advice you can give would be great
thanks alot
Anthony

Your basic logic is probably going to be something like this:
(a) read from the stream until you get a letter. (discard spaces at the beginning of a line, or between words)
(b) create a string or a string buffer that contains the letter you just read.
(c) read from the stream as long as you're getting letters, appending them to the end of the string or string buffer. When you get a character that isn't a letter, discard it, and return what you've built up.
This assumes you want to discard punctuation marks, spaces, carriage returns, etc.

Similar Messages

  • I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. What is the best way to do this

    I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. Even when I save it, the image quality at minimum the file size is 10.9 MB. What is the best way to do this

    @Barbara – What purpose is that PDF for? Print? Web?
    If web purpose, you could convert CMYK images to sRGB. That would reduce the file size as well.
    A final resort to bring down file size is:
    1. Print to PostScript
    2. Distill to PDF
    That would bring file size down even more. About 20%, depending on the images and other contents you are using, compared with the Acrobat Pro method. If you like you could send me a personal message, so we could exchange mail addresses. I could test for you. Just provide the highres PDF without any downsampling and transparency intact. Best provide a PDF/X-4.
    I will place the PDF in InDesign, print to PostScript, distill to PDF.
    Uwe

  • Why when I am trying to make a purchase from itunes credits do i need to re-enter my credit card info?

    why when I am trying to make a purchase from itunes credits do i need to re-enter my credit card info?

    If you are getting a message to contact iTunes Support then you can do so via this link and ask them why the message is appearing (we are fellow users here on these forums, we won't know why) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • How to make a class object  from a string representation of the same

    i have the name of a class whose object i want to make in the form of a string i.e. String s="S1"; i get this name after some prosessing. so what i want to do is to create an object of S1 which is actually one class that i have implemented.plz hlp. it is urgent.thnx in advance.

    reflection api...
    see java.lang.Class. Read the api docs.
    mostly, u need to do the following:
    Class myClass = Class.forName(s1);
    Object x = myClass.newInstance();
    reg
    s giri

  • I want to change my region App Store I tried all the instruction but it won't working help needed

    I want to change my App Store region from Kuwait to the U.S I tried so many time but is not working

    Does this help?
    iOS: Changing the signed-in iTunes Store account
              http://support.apple.com/kb/HT1311

  • Trying to make my website an RSS feed...need some help

    I want to make my site RSS distributable. I have been reading what I can find about RSS feeds but I am missing something.
    I can make a valid XML file that passes a feed validator, I can make an RSS feed button so you can enable my page to be added to an RSS feed reader but I am thinking my page HTML is still missing some appropriate tags to complete the process. They do not appear as "readable" even after added to a feed reader. It has been very difficult for me to locate a good tutotial to tell me what to do with my pages assets to make them adequately "readable." I don't know if that means it is so easy I'm over-thinking it or what.
    To maybe make it a little more problematic, I'm trying to do this with a site that includes a picture gallery, its a web comic. I have seen Web comic aggregators pull in WordPress sites with a clickable gallery that in theory is the same as what I have made at www.norestcomic.com but as I said, I can't legitimately pass my website all the way through a reader, even though it passes validation. I don't think the gallery itself is breaking anything.
    I would really prefer to not use WordPress because I like the potential for Muse and what it could mean to my site but the RSS feeds will become an important means of marketing and distribution for the site, so I do need to resolve this.
    As an aside would anyone know if RSS inclusion or RSS feed readers are coming as a widget? Can I officially request it? Thanks.
    Best,
    Matt

    Hi king-jans/Jorge,
    I am still trying to resolve this appropriately for my needs but I did make some progress.
    It took a number of trial and error attempts but I did make it so that some HTML code I added would make my site appear as an RSS readable page. HOWEVER, the HTML export of my site still maintains some of the great MUSE functionality so even with a good RSS header and trying to manually update my RSS support information RSS readers do not read it like other RSS capable sites. There are a number of RSS comic sites I was trying to link my site into and they all come back to me saying they can't read my site...usually treating me like an idiot because many non-technical people can do this though WordPress, etc. Me trying to have some control of the look and feel of my site is apparently a silly notion.
    I am still working on it and will update this thread if i can reach a better resolution.
    Best,
    Matt

  • Reading from serial , help needed

    Hello, I am a student trying to develop a Labview VI that talks with TDK blue2i module (with at style commands) via serial port, just like Hyperterminal.My VI consists of a while loop, inside of that I do VISA write, then VISA read using Bytes at serial port since answers are variable in lenght. When i run the program the first loop works ok ( i send message and get the right answer ) but in the second loop i still read the fisrt answer even if send a different command.
    Is there a way to make sure that buffer of the serial port is cleared after every reading?
    Sounds like a timing problem, Everything works well if I run the program Step by Step
    thanks

    "Francesco83" ha scritto nel messaggio
    news:[email protected]..
    > Hello, I am a student trying to develop a Labview VI that talks with
    > TDK blue2i module (with at style commands) via serial port, just like
    > Hyperterminal.My VI consists of a while loop, inside of that I do VISA
    > write, then VISA read using Bytes at serial port since answers are
    > variable in lenght. When i run the program the first loop works ok (
    > i send message and get the right answer ) but in the second loop i
    > still read the fisrt answer even if send a different command.
    > Is there a way to make sure that buffer of the serial port is cleared
    > after every reading?
    > Sounds like a timing problem, Everything works well if I run the
    > progra
    m Step by Step
    >
    > thanks
    Hi!
    I'm a student too, and I made a VI very similar to yours. My VI used the
    serial port to communicate with a modem, exchanging Hayes commands and
    answer from the modem.
    - Ma sei italiano anke tu! io non ho usato la VISA, ho usato solo le
    funzioni relative alla porta seriale messe in due o tre frame, non ricordo
    bene.. credo venga più complicato ma funziona! se vuoi vederlo scrivimi una
    mail! -
    Vicio

  • Class or interface problem..help needed PLZ.

    Here is my code..but i am constantly getting error message. :(
    public class VesselClass
         private double xCoord;
         private double yCoord;
         private double velocity;
         private double bearing;
    public vessel(double xCoord, double yCoord, double velocity, double bearing)
    this.setXCoord (xCoord);
    this.setYCoord (yCoord);
    this.setvelocity (velocity);
    this.setbearing (bearing);
    public double getXCoord();
    public boolean setXCoord(double x);
    if( x <= -1000.0 && x >= 1000.0)
         xCoord = true;
    else
              xCoord = false;
    return xCoord;
    public double getYCoord();
    public boolean setYCoord(double y);
         if (x <= -1000.0 && x >= 1000.0)
              yCoord = true;
         else
              yCoord = false;
         return yCoord;
    public double getVelocity();
    public boolean setVelocity(double v);
         if (v <= 0.0 && v >= 600.0)
              velocity = true;
         else
              velocity = false;
         return velocity;
    public double getBearing();                                                                           
    public boolean setBearing(double b)
         if (b <= 0.0 && b >= 360.0 )
              bearing = true;
         else
              bearing = false;
         return bearing;
    public String toString()
    return "( X-Coordinate = " + xCoord +" Y-Coordinate = " + yCoord + "V-Velocity = " + velocity +" B-Bearing = " + bearing +" )";
    public void display()
    System.out.println("(" + this.xCoord + "," + this.yCoord + "," + this.velocity + "," + this.bearing ")");
    Here is my method main()
    public class MyVessel
    public static void main(String[] arg)
    VesselClass vessel007 = new VesselClass(300.0, 500.0, 100.0, 250.0);
    System.out.println(vessel007.toString());
    Thanks a lot buddies.

    Okay. And did that message refer to a particular line
    of code, and you forgot to mention that piece of
    information? Somewhere before that line of code you
    have an extra closing brace (the "}" character). Get
    rid of that.It's far worse than that.
    Hopefully your code is indented, which would make it
    much easier to find extra braces. The stuff you
    posted wasn't.Normally I don't bother compiling code like this to see what's wrong, but IntelliJ made it easy to do.
    Your code could win a "worst code" contest. There are so many things wrong with what you wrote that it's a crying shame.
    Please go read a book on how to write Java. Your code is an example of how not to.
    Here's your code cleaned up so it compiles. It's still a bloody mess, but I have my own stuff to work on:
    package cruft;
    public class VesselClass
        private double xCoord;
        private double yCoord;
        private double velocity;
        private double bearing;
        public static void main(String[] arg)
            VesselClass vessel007 = new VesselClass(300.0, 500.0, 100.0, 250.0);
            System.out.println(vessel007.toString());
        public VesselClass(double xCoord, double yCoord, double velocity, double bearing)
            this.setXCoord(xCoord);
            this.setYCoord(yCoord);
            this.setVelocity(velocity);
            this.setBearing(bearing);
        public double getXCoord()
            return xCoord;
        public boolean setXCoord(double x)
            boolean thisClassIsCrap = true;
            return thisClassIsCrap;
        public double getYCoord()
            return yCoord;
        public boolean setYCoord(double y)
            if (y <= -1000.0 && y >= 1000.0)
                return true;
            else
                return false;
        public double getVelocity()
            return velocity;
        public boolean setVelocity(double v)
            if (v <= 0.0 && v >= 600.0)
                return true;
            else
                return false;
        public double getBearing()
            return bearing;
        public boolean setBearing(double b)
            if (b <= 0.0 && b >= 360.0)
                return true;
            else
                return false;
        public String toString
            return "( X-Coordinate = " + xCoord + " Y-Coordinate = " + yCoord + "V-Velocity = " + velocity + " B-Bearing = " + bearing + " )";
        public void display()
            System.out.println("(" + this.xCoord + "," + this.yCoord + "," + this.velocity + "," + this.bearing + ")");
    }%

  • How to make JPanel as JTable Cell Editor (Urgent help needed)

    Hi!
    I want to make JPanel (with a JTextField, 3 JLabels and 1 JTextArea) as cell editor for one column. Can somebody help me on this?
    Does anybody have any sample code? I will greatly appreciate ur help.
    Thanks,
    Snehal

    Okie. In "How to use JTables" page found in the JAVA website (there is a link from the JTable section of the JAVA API documentation), there is a sample code for a sample color chooser. What this does is, adds a button with its action listener set to pop up a color chooser window. In this, rendering is still through a JLabel.
    This example would be of good help to you. Plus, this example gives me a feeling that what u ask is possible.

  • Restore needed iPhone cannot make or receive calls....help needed

    Following an upgrade to IOS 6.0.1 my iphone 3 GS keeps on wanting a 'restore needed IPhone cannot make or receive calls restore from Itunes etc... I have done 2 restores and problem still occurs. Need some help, thankyou

    Take the device to Apple for evaluation and possible replacement.

  • Trying to make sense of div tags and css

    i know that i am a few years late here, but i am looking ot make the migration from using tables and switching over to div tags and css. i have watched a few tutorials on you tube and am trying to understand everything.
    please tell me if this is correct.  a div tag is basically a table and css is what is used to style that div tag to meet your needs, is this a correct assumption??
    if you go to my current site www.tankinz.com you can clearly see that the site is made up of tables, basically these boxes or tables contain a different item or package that a customer can click on and buy.  by using div tags and css would each of these boxes, or tables be their own div?
    sorry for sounding a bit moronic but i am trying to make sense of all of this.
    please help!

    Markup (html) contains elements, such as html, body, h1, h2, p, span, div and so forth. Hence a <div>-tag is part of an element; the other part being the </div>-tag.
    The element structure of many web sites is basically (using HTML5 element names)
    html
         head
         body
              header
              nav
              aside
              article
              footer
    These elements can be positioned and styled using style rules (css). Depending on the style rules, the above structure can take on many different styles, without ever touching the markup.
    Have a look here for a simple two-column layout using the same structure as above http://www.456bereastreet.com/lab/developing_with_web_standards/csslayout/2-col/

  • Themes are not present when trying to make a card.

    Themes are not present when trying to make a card.  ??

    Greetings,
    You need to reinstall iPhoto. 
    Questions:
    What version of iPhoto are you running (iPhoto > About iPhoto)?
    What version of the Mac OS are you running (Apple > About this Mac)?
    General steps:
    Remove the following files to the trash:
    Macintosh HD > Library > Application Support > iPhoto (if present)
    Macintosh HD > Library > Application Support > NetServices (if present)
    Macintosh HD > Library > Receipts > iPhoto (anything with iPhoto in the name)
    Macintosh HD > Applications > iPhoto
    Insert the iLife install disk you have or the Applications disk that came with your computer and reinstall iPhoto: http://support.apple.com/kb/HT2604
    Once installation is complete go to the Apple > Software update and repeat this until no additional updates are offered.
    Hope that helps.

  • Trying to make a square class

    hi i am trying to write a class that creates a square but it has to use to use the rectangle package so far i get an error cannot not find symbol on this line square = new Rectangle(0,0); and i get errors when i return my x and y variables if anyone has any ideas please i need some help thank you
    import java.awt.Rectangle;
    public class square
         private int length;
      private int width;
         public square ()
              square   = new Rectangle(0,0);
         public square (int length, int width)
             square = new Rectangle(0,0,length, width);
             this.length = length;
              this.width = width;
          /*Constructor:*/
        public square(int x, int y, int length, int width)
              square = new Rectangle(x, y, width, length);
                 this.length = length;
             this.width = width;
      public int getLength()
        return length;
      public int getWidth()
        return width;
      public int getX()
           return x;
      public int getY()
           return y;
      public void setBounds()
      return side;
    }

    You realize that by definition a square has equal sides? You don't need a width or a height, you just need a length. My "Square" class would only have a getLength() method and possibly setLength() if you want it to be mutable. If this is intended for use with AWT you could subclass Rectangle and guarantee that all sides are equal. Given your current design it would be trivially easy for me to create a Square that is in fact not a square at all.
    public class Square {
        private Rectangle rect;
        public Square(int x, int y, int length) {
            super();
            rect = new Rectangle(x, y, length, length);
        public Rectangle getRectangle() {
            return rect;
    }Of course, they could easily modify that Rectangle to make it not be a Square anymore. You could change the code to make a defensive copy. Then they could change the Rectangle, but it wouldn't affect you, so your Square would always return a square even if they made the returned Rectangle not a square at some later point. You'd do that like so:
      * Returns a square rectangle.  The returned Rectangle is mutable
      * and as such it could be mutated to no longer be a square.  It is the
      * responsibility of the client to ensure this does not happen.  Each
      * returned Rectangle is unique and mutations in one will not affect
      * the others.
      * @return A Rectangle that is a perfect square.
    public Rectangle getRectangle() {
        return new Rectangle(rect);
    }You could subclass Rectangle, but it's internals are exposed so you couldn't ever guarantee your Square was a square. Alternatively it looks like you could subclass Rectangle2D or RectangularShape and just be sure to override anything that could mutate your Square into something not a square. Also, you could just implement the Shape interface if that suits your purposes.
    Just some things to think about.

  • Captions of photos in Yahoo cover the bottom part of pic. Makes it hard to read text and also can't see whole photo. Tried reset Firefox but that didn't work.

    When going through photo galleries on Yahoo (in news, omg, etc.) the caption is displayed on top of the bottom 'fifth' of the photo. (The caption should be below the entire photo.) The way the pations are overlayed makes it difficult to read the text of the caption and worse, it makes it almost impossible to see the lower fifth of the photo. I tried resetting Firefox but that didn't change anything. I can't find any yahoo settings or OS X display setting that changed this. I'm using Firefox 25 on a macbook air running OS X 10. Are there any firefox settings that would improve this? Thanks.

    You can also try to reset the page zoom on pages that cause problems.
    *<b>View > Zoom > Reset</b> (Ctrl+0 (zero); Command+0 on Mac)
    *http://kb.mozillazine.org/Zoom_text_of_web_pages
    If you have made changes to Advanced font settings like increasing the minimum/default font size then try the default minimum setting "none" and the default font size 16 in case the current setting is causing problems.
    *Firefox > Preferences > Content : Fonts & Colors > Advanced > Minimum Font Size (none)
    Make sure that you allow pages to choose their own fonts.
    *Firefox > Preferences > Content : Fonts & Colors > Advanced: [X] "Allow pages to choose their own fonts, instead of my selections above"

  • To read value of name1 to eh_onsave and also to make uitility class.

    Hi,
    My requirement is to read (get) the value of name1(bp_head, bphead/account details,header,name1) to eh_onsave.
    Please suggest me to achieve this through iv_relation_name.
    I have written select statement in eh_onsave,they suggested to make utility class and call the method of that utility class to get values.
    How to to achieve this .
    Regards,
    Kishore.

    Hi,
    EH_ONSAVE method is in BPHEADOverview which has a context node BuilHeader bound to component controller context node PARTNER. You can directly read name1 from BUILHEADER, not necessary to use iv_relation_name. Use the below sample code in eh_onsave method,
    data: lr_ent       type ref to cl_crm_bol_entity,
             lv_name1 type string.
        lr_ent ?= me->typed_context->builheader->collection_wrapper->get_current( ).
        lv_name = lr_ent ->get_property_as_string( iv_attr_name = 'NAME1'  ).
    Regards,
    Arun

Maybe you are looking for

  • I've lost all my Apps on my itunes account and also on my computer. How can I get them back?

    I helped a lot of people with their iProblems, so it would be pleasure if somebody helped me. Please help me by having my apps back on my itunes account and my computer. I've spent a lot of money in it and suddenly they're gone. I really don't know h

  • Can't move pictures between tabs

    First, let me start out by saying I am new to Photoshop Elements. I am using PSE 12 for digital scrapbooking. Last week, all of a sudden, I am unable to use the move tool to drag and drop an imported picture from one tab to another. In the past I was

  • 2 fields with text on the same line

    Hi everyone, Could anyone let me know how I can get 2 fields with their text values in the same line. For eg: weight ______         unit of weight _____ i need both of the fields and text to be visible. Thanks/ Message was edited by:         Raj Kali

  • URGENT! Imac G5 Problem!

    i recently bought an imac g5 isight 17inch from ebay, the display isnt connected to the logic board, the logic board isnt screwed in but i have the screws .when i plug the psu in and turn it on, i get the fan noise and the light at the front but no i

  • MacBook doesn't tether to non apple products?

    If I use my Mac laptop as an internet hotspot through sharing, is there a way I can use it with non apple laptops, because the Internet does not work with my Asus.