Skip to content

平成22年度 秋期 ITパスポート試験 問90

This question's explanation and your answers so far.

問90
頻出度★★★

M さんは,総務課の N さんから宅配荷物の発送業務で利用する料金計算プログラム(以下,プログラムという)の作成を依頼された。そこで,N さんから聞いた料金計算の方法を基に次のように要件をまとめ,プログラムを作成した。 (1) 料金はサイズ区分と発送先の地区から表1の料金表で求める。サイズ区分は荷物の3辺計(荷物の縦,横,高さの長さの合計で1cm単位)と重量(1kg単位)を比較し,どちらか大きい方の区分を適用する。 なお,3辺計が140cm又は重量が20kgを超える荷物は受け付けない。 (2) 荷物の3辺計と重量,発送先の地区(A~D)を入力すると,料金を出力する。 表1 料金表(単位 円)

区分3辺計(cm)重量(kg)ABCD
180まで5まで1,3009501,1501,800
2100まで10まで1,6001,2001,4002,350
3140まで20まで2,0001,6001,8003,400

M さんは,プログラムを N さんに引き渡す前にテストを行うことにした。 テストに当たり,表2の出力結果表を作成し,これに基づいてテストデータを準備した。表2は,入力データが各列に示す Yes の組合せに該当する値であるときの正しい出力を,欄“予想出力”に記入したものである。 表2 出力結果表

123456…36
地区AYesYesYesYesYesYes…
B…
C…
D…Yes
3辺計(cm)80までYesYesYes…
100までYesYesYes…
140まで…Yes
重量(kg)5までYesYes…
10までYesYes…
20までYesYes…Yes
予想出力(円)a…
↑ b↑ c

注 網掛けの部分は,表示していない。 表2の出力結果表のaに入る予想出力はどれか。

出典 平成22年度 秋期 ITパスポート試験 問90
解説

問 90

  • Incorrectア

    1,300 yen is the fee for category 1 and district A in Table 1. It is the value you get when you look only at the 3-dimension total of up to 80 and decide on category 1, ignoring the weight of up to 20 (= category 3). The requirement says to apply whichever category is larger, so the smaller category 1 must not be chosen. A program that wrongly outputs 1,300 yen for this column is exactly the bug this test is meant to find.

  • Incorrectイ

    1,600 yen is the fee for category 2 and district A in Table 1 (it is also the fee for category 3 and district B). However, the third column has a 3-dimension total of up to 80, not up to 100, and a weight of up to 20, not up to 10, so it does not become category 2, and the district is A, not B. Nowhere in the requirements is there any calculation method that takes something midway between category 1 and category 3.

  • ウ

    正解 The correct answer is ウ (2,000 yen). Cell a is the expected output of the third column of Table 2, and that column has three input conditions: District = A, 3-dimension total = up to 80, and Weight = up to 20. The key here is requirement (1): the size category is decided by comparing the 3-dimension total with the weight and applying whichever category is larger. Looking at Table 1, a 3-dimension total of up to 80 is category 1, while a weight of up to 20 is category 3. Comparing the two, the larger one, category 3, is applied. After that you only need to read the value where the category 3 row and the district A column meet in Table 1, which gives 2,000 yen. In other words, this column does not mean the fee for a light and small parcel; it means the parcel is small but heavy, so it is charged by the category derived from the weight. Hence a = 2,000 yen.

  • Incorrectエ

    3,400 yen is the fee for category 3 and district D in Table 1. Judging it to be category 3 is correct, but the district has been misread. In the third column, Yes is marked at District = A; the column with Yes at D is column 36 at the far right of Table 2. Even if you match the category row correctly, taking the wrong district column makes the fee differ greatly.

ここがポイント
  • Rule for deciding the size category: when the category obtained from the 3-dimension total and the category obtained from the weight disagree, apply the larger one (the one with the higher fee). In the third column the 3-dimension total gives category 1 and the weight gives category 3, so category 3 is adopted, and the 2,000 yen where it crosses district A is the answer.
  • Table 2 lists all 36 combinations of input conditions (4 districts x 3 values of the 3-dimension total x 3 weights) and checks correctness only by the correspondence between the inputs and the expected outputs, not by the internal processing steps. This way of verifying that the output matches the specification without looking inside the program is called black-box testing, and the standard approach is to first build an expected-value table like Table 2 and then prepare the test data from it.
用語

Your answers