Skip to content

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

This question's explanation and your answers so far.

問91
頻出度★★★

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

注 網掛けの部分は,表示していない。 次の表は,テストデータ(地区,3辺計,重量)を用いて実際にテストを行った結果の一部である。この結果の判断として,適切なものはどれか。

地区3辺計(cm)重量(kg)出力結果(円)
C6051,400
C10181,800
D6052,350
D10183,400
出典 平成22年度 秋期 ITパスポート試験 問91
解説

問 91

  • ア

    正解 The fee is determined by finding the category from the sum of the 3 sides and the category from the weight separately, taking whichever category is larger, and then reading the amount from Table 1. In row 1, C / sum of 3 sides 60 cm / weight 5 kg: 60 cm falls in category 1 (up to 80) and 5 kg also falls in category 1 (up to 5), so category 1 applies and the correct fee is 1,150 yen for district C. However, the output is 1,400 yen, which is the value for category 2, district C in Table 1, so it is wrong. Row 3, D / 60 cm / 5 kg, is likewise category 1 and should be 1,800 yen, but the output is 2,350 yen (category 2, district D), which is also wrong. On the other hand, in row 2, C / 101 cm / 8 kg, 101 cm falls in category 3 (up to 140) and 8 kg in category 2, so the larger category 3 applies and the fee is 1,800 yen; row 4, D / 101 cm / 8 kg, is also category 3 at 3,400 yen, and both of these match the output and are correct. In other words, errors appear only for the input with a sum of 3 sides of 60 cm and a weight of 5 kg, so ア is appropriate.

  • Incorrectイ

    Category 3 applies to the two rows with a sum of 3 sides of 101 cm (C at 1,800 yen and D at 3,400 yen), and both match the category 3 values in Table 1 exactly, so they are correct. The rows that are actually wrong are instead the 60 cm / 5 kg rows, where category 1 should apply, so judging that the output is wrong when category 3 applies is the opposite of the truth.

  • Incorrectウ

    The correct fee for C / 60 cm / 5 kg is 1,150 yen and for D / 60 cm / 5 kg is 1,800 yen, which do not agree with the actual outputs of 1,400 yen and 2,350 yen. In 2 of the 4 rows the expected value differs from the output, so it cannot be said that there are no errors in the output results.

  • Incorrectエ

    The errors appear not only in district C but in district D as well. The output 2,350 yen for D / 60 cm / 5 kg is likewise the value of category 2, one step above the correct 1,800 yen (category 1, district D), so it is also wrong. What separates the wrong results from the correct ones is not the district but the input side: a sum of 3 sides of 60 cm and a weight of 5 kg.

ここがポイント
  • The size category is judged separately for the sum of the 3 sides and for the weight, and the larger of the two is applied. Since “up to 80” and “up to 5” include the boundary values, 60 cm and 5 kg fall in category 1, not category 2.
  • Judging whether a test passes means preparing the expected output first, comparing it with the actual output, and reading off the common pattern in the errors. Here the error “what should be category 1 is charged at category 2” appears regardless of the district, so the cause can be pinpointed on the side of the input conditions.
用語

Your answers