Quantcast
Viewing all articles
Browse latest Browse all 9

Product Method Overloading( It is the same person that asked last time) [duplicate]

I was working on this problem and could not do it and was not sure if I even understood what method overloading really is. Can anyone explain what it is (since the resources I found online were not really good) , and possibly fix the mistakes I've made?

The question is : overload the product method to allow for multiplying together other types of values:

two doublesan int and a doublea double and an intthree intsthree doubles

I'm getting errors saying : - Possible lossy conversion from double to int (line 13 , 16 , 19)- Product 2 / Product 3 is already defined- Method is expecting type int, int and type int,int,int was given(line 17)

   public class Product extends ConsoleProgram{    public void run()    {        int intValue = 5;        double doubleValue = 2.5;        int product1 = product(intValue, intValue);        System.out.println(product1);        // Use method overloading to define methods         // for each of the following method calls        double product2 =  product(doubleValue , doubleValue);        System.out.println(product1);        int product3 = product(intValue * intValue, intValue);        System.out.println(product1);        double product4 = product(intValue, doubleValue);        System.out.println(product1);        double product5 = product(doubleValue, intValue);        System.out.println(product1);        double product6 = product(doubleValue *doubleValue, doubleValue);        System.out.println(product1);    }    public int product(int one, int two)    {        return one * two;    }}

Thank you guys


Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>