Simple Question: How do I read from keyboard?

How do I read characters or integers from the keyboard?
InputStream with try/catch?
Can someone write code to show me how?

play with this a little...
it has the basics,
best i can do right now...
import java.io.* ;
import Car ;
class MilesPerGallon
  public static void main( String[] args )
      throws IOException
    BufferedReader userIn =
        new BufferedReader(
        new InputStreamReader( System.in ) );
    String line;
    int    startMiles, endMiles;
    double gallons;
    System.out.println("Enter first reading:" );
    line = userIn.readLine();
    startMiles = Integer.parseInt( line );
    System.out.println("Enter second reading:" );
    line = userIn.readLine();
    endMiles = Integer.parseInt( line );
    System.out.println("Enter gallons:" );
    line = userIn.readLine();
    gallons = Integer.parseInt( line );
    Car car = new Car(
        startMiles, endMiles, gallons  );
    System.out.println( "Miles per gallon is "
        + car.calculateMPG() );
}

Similar Messages

  • Very simple question, how do you configure windows 8.1 to use a SF card as the default install location for software applications?

    Very simple question, how do you configure windows 8.1 to use a SD card / external drive as the default install location for software applications? Primarily interested in apps installed from the windows store. This should be available in the settings
    charm within the windows store. This must have been overlooked in the development of windows 8.1 or is a bug.
    Regards, Bill
    * update
    I've tried modifying this key and the path:
    “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx”
    http://answers.microsoft.com/en-us/windows/forum/windows_8-windows_store/how-do-you-install-apps-in-windows-8-from-the/c4fbe2a8-fd3d-41c1-b9a6-6f881eed374f
    Also tried using symlinks as detailed here:
    http://social.technet.microsoft.com/Forums/windows/en-US/8eee52c2-db0f-4032-8c72-7cd999e8b41a/windows-8-apps-installing-to-secondary-drive?forum=w8itprogeneral

    Here's some links I've used to try to figure this out:
    http://social.technet.microsoft.com/Forums/windows/en-US/2dfc0cd9-7d1b-41de-abce-e03fb6a5a383/metro-apps-not-working-in-windows-8-pro-x64-after-moving-users-and-programdata-folders?forum=w8itproinstall
    http://social.technet.microsoft.com/Forums/windows/en-US/8eee52c2-db0f-4032-8c72-7cd999e8b41a/windows-8-apps-installing-to-secondary-drive?forum=w8itprogeneral
    http://social.technet.microsoft.com/Forums/windows/de-DE/f5e33ac9-beab-4b99-b3ca-7cb5e6f415e4/how-do-you-change-metro-apps-default-install-location?forum=w8itprogeneral
    Regards, Bill
    The registry method does not work with 8.1.  I found this out the hard way.  Doing it on 8.1 will leave you reinstalling the OS if you didn't do a SRP beforehand.

  • HT4753 I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    It's actually even easier than using Save As to see the full path to the currently open document. Just do a "Secondary click" on the document title in its window's title bar.
    Like you, I relied upon Save As my whole life to check a file's location and considered it a must-have capability. Turns out it's even faster to use the single-click method to reveal the full path to the open document. It displays the entire path to the current document starting from the level of your Mac, and works for files stored on drives as well as iCloud.
    If you're not sure how to do a secondary click, go into System Preferences, select Trackpad, Point & Click to find the current preference for secondary click on your Mac. If you happen to have a mouse with more than one button, it's probably the right button. As a trackpad user, I check the box to "Click or tap with two fingers," so a simple two finger tap on the title of an open document reveals its full path. This feature actually has been around for a very long time.
    Note that this is not the same thing as the Autosave and Versions menu, which is exposed using a little drop down triangle to the right of the title. There is no visual clue for the presence of this feature - you just have to know it's there, probably because this feature goes all the way back to pre-OS X days.

  • Simple question - How do you make an onchange event occur in a select list

    Simple question - How do you make an onchange event occur in a select list to fire a process?
    Thanks

    1) Using ApEx Selec list on Submit Item.
    You will create a PL/SQL Process after Submit. -> Conditional Type Request = Expression1. -> Expression1 is the name of your Select List. Process Source - > Procedure you like. For example depending of your select List value you will add rows in different tables.
    2) Javascript This example will change a System parameter value when changed
    <select id="P3_SUBSYSTEM" onchange="location.href='f?p=101:3:2164422329953284::NO::P3_SUBSYSTEM:'+this.options[selectedIndex].value;" size="1" name="p_t21">

  • How can I read from a file line by line?

    Hi!
    Could someone post some code or explain how can I read from a file, and want I to read a line each time. How can I go to line number N?
    Thanks

    hi,
    u can try this:
    try     {
          // open text file
          BufferedReader in = new BufferedReader(new FileReader(fileName));
          String line=in.readLine();
          while((line=in.readLine()) != null) {
          System.out.println(line);
          }The go to line number N i m not so sure.
    Cheers
    Jerry

  • New comer ask 2 simple questions:how to set the use of the right click of

    New comer ask 2 simple questions:how to set the use of the right click of your mouse?
    I don't know why when i click the right button of my mouse in logic, sometimes it's the same funcion as my left one, some times it's the same function that opens the tool menu....But in MacOSX,it's all okay.Just the weired thing in logic ,please help
    2.is there any kind of filter in Score? I mean, in midi track I have a C1 note, and I don't want the C1 note shown in my score, I want every note show which are above C2, like a filter. I think this is helpful dealling with some keyswich things,how can we do that?

    In Preferences -> Global -> Editing you can choose weather right click is assignable or opens the tools box.
    Not to sure about the score dude

  • Simple Question: How to search for a date value in SELECT

    Probabily a simple question, but in a SELECT statement, how do you do a search for a date value in the WHERE clause?
    example:
    Select * From Example
    Where date = 01/01/2001
    I know its not as simple as that, but what change has to occur to make it do what that example implies?
    Thanks In Advance.

    If you want to avoid the conversion part(to_date) you will need to specify the date in the format as ur nls date format.so the same query might not work if you change ur nls date format.
    so it is advisable to give it in general format.
    ie where date_col=to_date(01-01-2000,'dd-mm-yyyy')

  • Utl_file how to start reading from a certain position?

    Hi all,
    i'm currently using utl_file to read a text file and import to db. i have managed to do it. however i would like to avoid reading the first line as it is the header. i would also like to avoid the last line as it is the footer.
    how do i use the function of get line to start reading at a certain position? i am also able to get the length but i do not know how to make it start reading from a certain position.
    the length of the first line will always be 9 and length for the last line would be 51.
    here's my code so far:
    set serveroutput on
    declare
    vSFile   utl_file.file_type;
    vNewLine VARCHAR2(4000);
    file_name VARCHAR2(200) := 'read.txt';
    v_exist     BOOLEAN;
    v_length number;
    blocksize   NUMBER;
    temp_value varchar2 (4000);
    BEGIN
      vSFile := utl_file.fopen('MYDIR', file_name,'r');
      IF utl_file.is_open(vSFile) THEN
        LOOP
          BEGIN
            utl_file.get_line(vSFile, vNewLine);
            IF vNewLine IS NULL THEN
              EXIT;
            END IF;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
              EXIT;
          END;
        END LOOP;
        UTL_FILE.FGETATTR('MYDIR',file_name,v_exist,v_length,blocksize);
        dbms_output.put_line(v_length);
        COMMIT;
      END IF;
      utl_file.fclose(vSFile);
    END read_demo;

    Hi,
    utl_file has an fseek procedure for moving the file pointer around in a file, either absolute or relative number of bytes.
    It's in the documentation, I'm surprised you didn't see it there when you looked before going to the hassle of asking us a question.
    Andre

  • Simple question - How to find date

    Hi Experts,
    I have a simple question on date. Suppose today is Jan 4, 2010. I have to find out Jan 1, 2007 using Java code.
    I have used following code. This code will work for 2010 and 2011 properly. However it won't work properly after Feb 28, 2012. Please see "dayInMillis*1096 " portion of code. Here 365365366 = 1096.
    How I can avoid this hard coding. Do we have any simple way to get Jan 1, 2007 even without using following code.
         Calendar calendar = Calendar.getInstance();
         int lastDate = calendar.getActualMaximum(Calendar.DATE);
         int firstDate = calendar.getActualMinimum(Calendar.DATE);
         int todayDate = calendar.get(Calendar.DATE);
         int dayofyear = calendar.get(Calendar.DAY_OF_YEAR);
         java.sql.Date currentdate = new java.sql.Date(System.currentTimeMillis());
         long dayInMillis = 1000 * 60 * 60 *24; //1 day
         wdContext.currentContextElement().setFromDate(new Date(System.currentTimeMillis() - dayInMillis*1096 - ((dayofyear-1)*dayInMillis)));
    Please help.
    Regards,
    Gary

    Hi Gary,
    I am not pretty much clear with your question, whatever i have understood, i have found a way to get the previous date given the current date.
    Below is the code for the same.
                           Calendar now = Calendar.getInstance();//Jan 4, 2010
           String nowDateStr = DateFormat.getDateInstance().format(now.getTime());
           System.out.println("date now : " +nowDateStr);
           now.add(Calendar.YEAR, -3);//2007
           now.add(Calendar.DATE, -3);//1st
           now.add(Calendar.MONTH, 0);//No change in month, Jan.
           String changedDateStr = DateFormat.getDateInstance().format(now.getTime());
           System.out.println("date changed : " +changedDateStr);

  • Very simple question-how to fill a shape I draw with color

    hi. I am new to photoshop and having a lot of trouble selecting any shape that I draw. I am trying to do a tutorial that involves filling a canvas with gray, then drawing a smaller white rectangle inside of the larger gray canvas/rectangle. (I did not forget to unlock the background).
    My question: how do i select and fill (with white) the second rectangle I draw on top of the larger gray rectangle???
    In general, I cannot figure out how to select and/or fill any shape I draw using the rectangle tool. Likewise, the marque shape tools are no help as I cannot seem to draw a marque on my gray rectangle in order to select it and fill it with a white fill. I have also tried to use a "fill layer."
    I am almost certain that something is wrong with my computer(I reset the settings), but then again I have not used photoshop in over a year. Any help  will be greatly appreciated.

    The Rectangle Tool sgould create a Work Path, Shape Layer or Fill Pixels according to the Settings in the Options Bar.
    The Rectangular Marquee Tool should create a Selection, which you could Edit > Fill or use as a Layer Mask for a Solid Color Layer.
    Could you please post a screenshot with the pertinent Panels visible?

  • Data reading and writing problem? how to set " Read from Measurment File express.vi​" 's readout datasize?

    Dear all,
    I want to use Labview to process a data.
    Now I have a array in a text file.
    this array is very very big. which is at least row*col = 6 * 100000;
    the column size always 6,
    but the row size is ramdom, some times is very big, like bigger than 65535,
    when I use "read from measurement file express.vi" to read this file, the array I could get always 6*5339, I don't know why. the column size is always 5339.
    and then I delete the 1st row of the array and then write into a txt file via "write measurement file express. vi", it takes a very long time. almost computer has no response. after a while, no file was creat to record the data.
    is there an efficient way to process such big data file and store the processed file into a new file
    thank you very much
    Jack
    Message Edited by weichengatech on 03-09-2006 12:00 AM

    Hello,
    There’s no real efficient way to read the file if you don’t
    know exactly how many rows of data you have. 
    Your going to just have to read a row at a time and add the results to
    the end of an array (granted for the clever programmers there are some more
    efficient ways to do this than just with ‘build array’).  I would start by asking you how much
    information you know about the file and what the exact structure of it is (i.e.
    is it a binary file, a tab delimited file, or a LVM file)?  Could you provide a screenshot of the code
    you are running? If you provide a little more information on the file structure
    we might be able to contribute some additional information.
    Look forward to hearing back from you-
    Travis M
    LabVIEW R&D
    National Instruments

  • How do I read from one table and write to another identical table?

    I am very new to Oracle. I am trying to do something that should be very simple.
    I am trying to read from one table in SQL and then write to another
    Identically formatted table. I keep getting various errors. Could someone please
    post some vey simple code that will work so that I can play around with it?
    Any help would be greatly appreciated.
    Thanks,
    Ron

    Thanks, but I must be missing something.
    I have two tables, SONGLIST and SETLIST.
    The second line by itself works just fine on either table.
    Here is the code I used following your seggestion, along with it's error message.
    Hope you can help. Thanks again...
    INSERT INTO SETLIST
    SELECT TITLE FROM SONGLIST WHERE ROTATION <> 'X'
    ORA-00947: not enough values

  • Simple Question - How do I deploy custom taglibs to Oracle 9iAS r2?

    Simple question.
    There are lots of simple examples on JSP custom tags that have
    a .tld file, a .java file with the handler class, and a .jsp
    file that calls the custom tag to test it.
    My question is, lets say I have a .tld file, a .java file and
    a .jsp file for a tag example. How do I deploy them to
    Oracle 9iAS r2? I'd like to code an example and deploy it,
    but I'm stuck. I'm using Jdeveloper 9i, and have compiled the
    .java file and included it and the .tld in a Custom Taglib JAR.
    How is this JAR deployed to Oracle 9iAS, considering that the
    Enterprise Manager only deploys WAR and EAR files? How do
    a configure a web app to use the custom tags...
    This should be simple -- maybe its too simple so I'm stuck!

    check out ojspdemos which comes with the product.
    Also see
    http://otn.oracle.com/tech/java/oc4j/doc_library/902/jsp/taglibs.htm#1004903
    -Prasad

  • How to keep Reader from being installed if running Pro? Running Acrobat X Pro. Occaisionally, a website with a PDF triggers Reader to be installed on my system. NEVER want reader (that's why i bought Pro). How do i keep Reader from EVER being installed?

    Running Acrobat X Pro.
    Occasionally, a website with a PDF triggers Reader to be installed on my system.
    NEVER want reader (that's why i bought Pro).
    How do i keep Reader from EVER being installed?

    I don't get a pop-up. Something triggers the Reader installer to be loaded on my system. This occurs without my knowledge. Then, the next time i go to open a PDF, instead of it opening immediately with Acrobat Pro, I get the first screen of the installation stuff for Reader (Accept/Decline Terms of use, etc.). At this point, i get out of the install, go into control panel and uninstall Reader (which is listed as a loaded program, even though i haven't finished the install). After i uninstall reader and open a PDF, it opens correctly with Acrobat Pro. This happens once or twice a month at least. Is it possible that the Adobe Acrobat Update Service task loads Reader on my system at some interval? How do i block Reader form EVER being installed or loaded?

  • How do i read from/write to FieldPoint modules in LabView 8.5?

    Is there a new way to read from/write to FieldPoint modules in LabView 8.5?  I made a .vi in LabView 8.0 using the FieldPoint icon under 'Measurement I/O' on the Functions Palette (to read from and write to different modules), but now, after transferring the program to a new computer with LabView 8.5, those icons are not listed under 'Measurement I/O'.  The FieldPoint items do show up in MAX so I know that they're connected properly. 
    Did I miss something when installing the new LV 8.5? 
    Any help would be appreciated.
    Thanks!

    Hello,
    As Mike said, it is important to reinstall any drivers that you need, such as FieldPoint, after
    installing a new version of LabVIEW so that the new version of LabVIEW will contain the necessary functions for communicating with your specific hardware.  The same goes for any toolkits or software modules that you may have. 
    Currently, only FieldPoint
    6.0 installs support for LabVIEW 8.5.  The installer for FieldPoint 6.0 is packaged with the August 2007, November 2007, and February 2008 Device Driver CDs that shipped with LabVIEW.  The February 2008 Device Driver CD can also be found online at:
    http://joule.ni.com/nidu/cds/view/p/id/991/lang/en
    You will notice on the FieldPoint
    5.0.1 installer there are only support options for LabVIEW versions up
    to 8.2.1.
    Take care!
    FieldKam
    Kameralina
    Ask NI (ni.com/ask)
    Search The KnowledgeBase
    NI Developer Zone
    Measure It. Fix It. ni.com/greenengineering/
    NI Vision ni.com/vision/

Maybe you are looking for