Suppose that we are selling boxes of candy for a fund-raiser. We have five kinds of candy to sell: Mints, Chocolates with Nuts, Chewy Chocolates, Dark Chocolate Creams, and Sugar Free Suckers. We will record a customer’s order as an array of five integers, representing the number of boxes of each kind of candy. Write a static method combineOrder that takes two orders as its arguments and returns an array that represents the combined orders. For example, if order1 contains 0, 0, 3, 4, and 7, and order2 contains 0, 4, 0, 1, and 2, the method should return an array containing 0, 4, 3, 5, and 9.

What will be an ideal response?


```
public static int[] combineOrder(int[] order1, int[] order2){

// Find the number of values that will be in the result
int[] combinedOrder = new int[5];
for(int i=0; i<5; i++){
combinedOrder[i] = order1[i] + order2[i];
}

return combinedOrder;
}
```

Computer Science & Information Technology

You might also like to view...

Determine the number of network (N), subnet (S), and host (H) bits. Which of the following statements are TRUE?

A) N = 23 B) S = 14 C) H = 5 D) S = 5

Computer Science & Information Technology

If pt is declared as a pointer to a structure of type Employee, ____ refers to the variable whose address is in the pt.idNum variable.

A. (*pt).idNum B. *pt.idNum C. pt->idNum D. (*pt.)idNum

Computer Science & Information Technology

Which of the following are two main components on the motherboard?

A. memory and storage B. interpreter and compiler C. processor and memory D. compiler and processor

Computer Science & Information Technology

The Edge Animate placeholder may appear larger in Dreamweaver than its eventual appearance in a browser.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology