110k views
1 vote
If you need a function to get both the number of items and the cost per item from a user, which would be a good function declaration to use?

1 Answer

1 vote

Answer:

double costAndNumItems (int numOfItems, double costPerItem){

return 0;

}

Step-by-step explanation:

Above is how functions/methods are declared in Java programming language. We speficify the functions return type (double in this case), this is followed by the function's name costAndNumItems and then the arguments list which specifies the list of parameters that this function will accept. (numOfItems and costPerItem) followed by an open and close braces. Inside the braces is where the code for the functions behaviour is defined.

User Cheryl
by
5.5k points