120k views
1 vote
"add" is a method that accepts two int arguments and returns their sum .Two int variables , euroSales and asiaSales, have already been declared and initialized . Another int variable , eurasiaSales, has already been declared .Write a statement that calls add to compute the sum of euroSales and asiaSales and that stores this value in eurasiaSales.Assume that add is defined in the same class that calls it.

User Intelis
by
5.1k points

1 Answer

2 votes

Answer:

The answer to this question can be given as:

Statement:

//declare method add with two-parameter.

public static int add(int euroSales, int asiaSales)

{

return euroSales+asiaSales;

//return value.

}

public static void main(String[] args)

//declare main function

{

int eurasiaSales;

//declare integer variable

eurasiaSales=add(4,7);

//calling function by passing value in arguments.

//variable hold return value.

System.out.print("Sum is:"+eurasiaSales); //print value.

}

Explanation:

In the above statement firstly we declare the function that name is already given in the question that is add() function. In this function, we pass two integer variables as a parameter that is euroSales and asiaSales. This function returns the sum of passing variable. Then we declare the main function in that function we declare an integer variable that is eurasiaSales that hold the return values of the add function in the last we print eurasiaSales variable value.

User Ritwik
by
5.9k points