Why was I asked to return an array for this interview task?

I am 2nd-year computer science student and I just got back from my first ever interview.

Basically at the end my interviewer asked me to write a function that takes two arguments, an amount in pounds and a tax percentage and then return an array with the tax amount.

I eventually wrote something like this after some trial and error:

public static double[] taxAmount (double pounds, double taxPercentage) {
    double taxAmount = pounds * taxPercentage/100;
    double[] taxAmountArray = new double[1];
    taxAmountArray[0] = taxAmount;
    return taxAmountArray;

It worked and he seemed happy, what I am wondering is why I needed to return an array for this task? I just feel like the question was really stupid the array is useless for this task right?. Am I missing something?


The interviewer most likely wanted you to comment on why you were being asked to return the tax amount in an array, just like you are doing right now.

If you voiced your confusion during the interview like you did in this question, you passed the test.

Essentially the question was likely designed not just to check if you could identify the bizarreness of returning an array, but also whether you would have the confidence to be able to communicate your confusion and challenge your future supervisor if you got the job.

The interviewer probably wanted you to interact more so that he could see how you think, and approach the problem and for this particular instance he probably wanted you to ask why you should return an array.

Need Your Help

How to properly ignore exceptions

python exception try-except

When you just want to do a try-except without handling the exception, how do you do it in Python?

Normalize table to 3rd normal form

database database-design relational-database normalization database-schema

This questions is obviously a homework question. I can't understand my professor and have no idea what he said during the election. I need to make step by step instructions to normalize the following