32.2k views
2 votes
Write a calling statement for the following code segment in Java: public static int sum(int num1, int num2, String name) { int result = num1 + num2; System.out.println("Hi " + name + ", the two numbers you gave me are: " + num1 + " " + num2); return result; } Function Integer sum(Integer num1, Integer num2, String name) Integer result = num1 + num2 Display "Hi " + name + ", the two numbers you gave me are: ", num1, " ", num2 Return result End Function Write a calling statement to the function in Java or Pseudocode. You may use any value of appropriate data samples to demonstrate your understanding.

User Dremme
by
5.6k points

1 Answer

2 votes

Answer:

Following are the calling of the given question

public static void main(String[] args) // main function

{

int store; // variable declaration

store = sum(32,15,"san"); // Calling of sum()

System.out.println(" TheValue returned by sum() : "+store); // display

}

Step-by-step explanation:

Following are the description of the above statement

  • Here is the name of function is sum() In the sum() function definition there are 3 parameter in there signature i.e two "int" type and 1 is "string" type .
  • In the main function we declared the variable store i,e is used for storing the result of sum() it means it storing the result of value that is returning from the definition of sum() function .
  • After that calling the function by there name and passing three parameter under it sum(32,15,"san"); and store in the "store" variable.
  • Finally print the value by using system.out.println ().
User Newnewbie
by
5.2k points