Results 1 to 4 of 4
  1. #1
    drmarx is offline Member
    Join Date
    Nov 2009
    Posts
    2
    Rep Power
    0

    Default finding max and min with inheritance with two input integer

    somebody help me this one pls. i m so new to java and don't hav idea for that.
    pls help.

  2. #2
    Tshegofatsom is offline Member
    Join Date
    Apr 2009
    Location
    Pretoria, Gauteng, South Africa
    Posts
    43
    Rep Power
    0

    Default

    I dont think your question is descriptive enough. where is the code you tried writing?
    Tshegofatso Manakana
    a.k.a Untouchable

  3. #3
    drmarx is offline Member
    Join Date
    Nov 2009
    Posts
    2
    Rep Power
    0

    Default

    here is the code, i don't know how to assign input from command line, pls advice.

    class abc extends efg{

    public int max(int a,int b){

    int c=0;

    if (a>b)
    c=a;
    else
    c=b;

    System.out.println("Max " + c);
    return c;
    }

    public static void main(String args[]) {
    int d=90;
    int e=80;
    abc v=new abc();
    v.min();
    v.max(d,e);

    }
    }

    class efg{

    public int min() {
    int a= 1;
    int b=30;
    int c=0;

    if (a<b)
    c=a;
    else
    c=b;

    System.out.println("Min " + c);
    return c;
    }
    }

  4. #4
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    don't know how to assign input from command line
    Java Code:
    public class Test {
        Test(int[] ints) {
            for(int i = 0; i < ints.length; i++) {
                System.out.printf("ints[%d] = %d%n", i, ints[i]);
            }
        }
    
        public static void main(String[] args) {
            int[] n = new int[0];
            if(args.length > 0) {
                n = new int[args.length];
                for(int i = 0; i < n.length; i++) {
                    n[i] = Integer.parseInt(args[i]);
                }
            }
            new Test(n);
        }
    }
    Java Code:
    C:\jexp>java Test 1 2 3 4 5
    ints[0] = 1
    ints[1] = 2
    ints[2] = 3
    ints[3] = 4
    ints[4] = 5

Similar Threads

  1. how to know the input value of integer
    By ran830421 in forum New To Java
    Replies: 15
    Last Post: 11-18-2009, 09:01 PM
  2. Input technique for unknown lines of input
    By ducreative in forum New To Java
    Replies: 16
    Last Post: 09-23-2009, 09:26 AM
  3. input to an integer (simply)
    By chitwood in forum Advanced Java
    Replies: 3
    Last Post: 03-18-2009, 06:34 AM
  4. Finding largest and smallest integer
    By mlhazan in forum New To Java
    Replies: 2
    Last Post: 01-12-2008, 10:30 PM
  5. how to take input and verify input in Java programs
    By bilal_ali_java in forum Advanced Java
    Replies: 0
    Last Post: 07-21-2007, 08:46 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
  •