• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change Program (How can I get two inputs)

 
Juan Sifuentes
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am making a simple change program. I need to get two inputs (ammount due and payed). I am using notepad and command promt.
I learned to get 1 input by writing this in notepad

"String s = args [0];"

and I run my program and enter single input in the command prompt by entering

"java (Class name) (input statement)"

What code can I used to get one input then another?
I want to ask

Ammount Due?
(enter 1st input)
Ammount Payed?
(enter 2nd input)
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"String s = args [0];"

and I run my program and enter single input in the command prompt by entering

"java (Class name) (input statement)"


Juan,

command line argumemts are not limited to one. you can use more than one command line arguments to Java program.




Also if you need to ask for input and user needs to enter. then have look at Scanner API
 
Juan Sifuentes
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that helps.
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Juan Sifuentes wrote:I want to ask

Ammount Due?
(enter 1st input)
Ammount Payed?
(enter 2nd input)

Check out System.console(), in particular the readLine() methods. Keep in mind that System.console() can return null, so check against that.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Scanner class is probably easier to use than Console.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic