Ask Question
11 April, 23:53

Assume that two parallel arrays have been declared and initialized: healthOption an array of type char that contains letter codes for different healthcare options and annualCost an array of type int. The i-th element of annualCost indicates the annual cost of the i-th element of healthOption. In addition, there is an char variable, best2. Write the code necessary to assign to best2 the health option with the lower annual cost, considering only the first two healthcare options. Thus, if the values of healthOption are 'B', 'Q', 'W', 'Z' and the values of annualCost are 8430, 9400, 7050, 6400 your code would assign 'B' to best2 because 8430 is less than 9400 and is associated with 'B' in the parallel array. (We ignore 'W' and 'Z' because we are considering only the first two options.)

+1
Answers (1)
  1. 12 April, 00:18
    0
    if (annualCost[0] < annualCost[1])

    {

    best2 = healthOption[0];

    }

    else

    {best2 = healthOption[1];

    }

    Explanation:

    The required code is given above.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assume that two parallel arrays have been declared and initialized: healthOption an array of type char that contains letter codes for ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers