Results 1 to 5 of 5
  1. #1
    Tejeshwar is offline Member
    Join Date
    Apr 2016
    Posts
    2
    Rep Power
    0

    Question need urjent help with this little project

    hey, there is this little project that I need help with, I am completely new to java, and have no clue how to do it, can someone please help me with writing the code for the following:

    write a java programme to perform multiplication of two numbers inside this,
    create class (A) to accept one value from user,
    create class (b) to accept second value from user,
    create Class (c) and perfom a multiplication operation in this class
    and also display this result using inheritance.

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: need urjent help with this little project

    This is homework. You won't get that done for you here. Plenty people here are willing to help with the problems that you encounter, but you have to show your effort too.
    Think of:
    - Show us the code have you made so far
    - Ask questions about the exact part you don't understand
    - Include any compilation error
    - Include the output, and describe the expected output
    - etc....
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,807
    Rep Power
    12

    Default Re: need urjent help with this little project

    Three classes for such a simple program <shudder>

  4. #4
    warelephant is offline Member
    Join Date
    Apr 2016
    Posts
    2
    Rep Power
    0

    Default Re: need urjent help with this little project

    First time programmer may get confused with class and objects.

    I do not have the information about how the inheritance should play here. You may need to figure out yourself.
    ==========================================
    import java.util.Scanner;
    public class C
    { int multiply(int a, int b){return a*b;}
    public static void main(String[] args){
    A a = new A(); B b = new B(); C c = new C();
    System.out.println("A="+a.get()+" times B="+b.get()+" ="+c.multiply(a.get(), b.get()));
    }
    }
    class A{
    int a;
    A(){
    System.out.print("Enter A=");
    Scanner in = new Scanner(System.in);
    a = in.nextInt(); in.close();
    }
    int get(){
    return a;
    }
    }
    class B{
    int b;
    B(){
    System.out.print("Enter B=");
    Scanner in = new Scanner(System.in);
    b = in.nextInt(); in.close();
    }
    int get(){
    return b;
    }
    }
    =============================
    removed advert
    Last edited by Tolls; 04-08-2016 at 09:38 AM. Reason: remove advert

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: need urjent help with this little project

    This forum to frown on spoon-feeding solutions. The way to help the OP is to ask specific questions to determine what parts of the assignment the OP does not understand.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 5
    Last Post: 05-13-2015, 11:57 AM
  2. Convert Java Project (Old Style) to Maven Project
    By oliosien in forum Apache Maven
    Replies: 1
    Last Post: 03-23-2015, 03:22 PM
  3. Replies: 2
    Last Post: 06-26-2014, 07:43 PM
  4. Replies: 7
    Last Post: 11-27-2012, 10:16 AM
  5. Creating a project in eclipse from existing project
    By Suraiya in forum New To Java
    Replies: 1
    Last Post: 10-08-2011, 09:14 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
  •