simple java prompt

Discussion in 'Java' started by DummyMan, Sep 24, 2003.

  1. DummyMan

    DummyMan Guest

    I was wondering could someone tell me the code to display a simple
    prompt for a number in java with the system.println commands. So that
    I could prompt the user for a number, take the number and multiply it
    by 4, and return the output on the screen. Thanks.
     
    DummyMan, Sep 24, 2003
    #1
    1. Advertising

  2. DummyMan wrote:

    > I was wondering could someone tell me the code to display a simple
    > prompt for a number in java with the system.println commands. So that
    > I could prompt the user for a number, take the number and multiply it
    > by 4, and return the output on the screen. Thanks.


    Most here could give you code for your task, and one or two might even
    do so. On the other hand, you'll get more out of it if you consult your
    text and / or ask your instructor, then work it out for yourself. I'll
    give you a few hints, though:

    () Every Java program is constituted by one or more classes, so you'll
    need to write a class.

    () A class that serves as the main class of an application must have a
    method with this signature:

    public static void main(String[] args)

    () The static method described above is what the JVM will run when you
    feed it your class; for a task as simple as you describe, you can
    probably put all your task-specific code there.


    If you couldn't have gotten at least those things out of your text /
    instructor, then you need a better text / instructor.


    John Bollinger
     
    John C. Bollinger, Sep 24, 2003
    #2
    1. Advertising

  3. DummyMan:

    >I was wondering could someone tell me the code to display a simple
    >prompt for a number in java with the system.println commands.


    System.out.println, not system.println.

    >So that
    >I could prompt the user for a number, take the number and multiply it
    >by 4, and return the output on the screen. Thanks.


    - wrap a BufferedReader around an InputStreamReader around System.in
    - convert the user input from String to int with java.lang.Integer
    - multiply by 4
    - write back using System.out.println

    If with that help the task is still totally out of your league, ask
    your course tutor, because in that case there's something wrong with
    the course.

    Regards,
    Marco
    --
    Please reply in the newsgroup, not by email!
    Java programming tips: http://jiu.sourceforge.net/javatips.html
    Other Java pages: http://www.geocities.com/marcoschmidt.geo/java.html
     
    Marco Schmidt, Sep 25, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tomer Ben-David

    Open dos command prompt from java

    Tomer Ben-David, May 16, 2004, in forum: Java
    Replies:
    9
    Views:
    74,506
    mrgowthamkumar
    Feb 22, 2009
  2. Dylan Parry

    A simple one: Prompt to open file?

    Dylan Parry, Jun 2, 2005, in forum: HTML
    Replies:
    2
    Views:
    463
    Alan Searle
    Jun 2, 2005
  3. gaurav kashyap
    Replies:
    2
    Views:
    623
    gaurav kashyap
    Oct 30, 2008
  4. gaurav kashyap
    Replies:
    3
    Views:
    691
    gaurav kashyap
    Oct 31, 2008
  5. Mel
    Replies:
    10
    Views:
    3,143
    Sailaja Appi
    Feb 13, 2009
Loading...

Share This Page