Results 1 to 3 of 3
  1. #1
    babyvoke is offline Member
    Join Date
    Aug 2012
    Posts
    1
    Rep Power
    0

    Question don't know how to use the command line arguement

    here're my 2 programs which worked well in console

    1given two integer numbers you will see the result of their sum/difference/product/quotient(only the integer part)/mod
    import java.util.Scanner;
    public class Numbers
    {
    public static void main(String[] args) {

    Scanner putin = new Scanner (System.in);
    int a = putin.nextInt();
    int b = putin.nextInt();
    System.out.println(a + b);
    System.out.println(a - b);
    System.out.println(a * b);
    System.out.println(a / b);
    System.out.println(a % b);
    }

    }


    2、it will be two sentences when it comes to the results
    import java.util.Scanner;

    public class Greetings {
    public static void main(String[] args) {
    Scanner keyboard = new Scanner (System.in);
    String a = keyboard.next(), b = keyboard.next();
    System.out.println("Hello " + a +" from " + b + ".");
    System.out.print("I'VE ALWAYS WANTED TO GO TO");
    System.out.println(b.toUpperCase() + ".");
    }
    }

    but i need to use the command line argument to make it test well in Unix, I don't understand how to translate the program so that it can work well with the command line argument. can you help me with it?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: don't know how to use the command line arguement

    Please have a look at this tutorial which explains how to get and use command line arguments.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,421
    Rep Power
    20

    Default Re: don't know how to use the command line arguement

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Command Line
    By dougie1809 in forum New To Java
    Replies: 7
    Last Post: 03-12-2012, 11:47 AM
  2. Replies: 16
    Last Post: 09-17-2011, 03:41 AM
  3. can i run line by line command in netbean?
    By choconlongxu in forum NetBeans
    Replies: 1
    Last Post: 07-19-2010, 09:41 PM
  4. Replies: 2
    Last Post: 07-02-2010, 03:20 PM
  5. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 01:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •