simple java prompt

D

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. 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.
 
J

John C. Bollinger

DummyMan said:
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
(e-mail address removed)
 
M

Marco Schmidt

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top