1Easy
0/1

A C# program calculates shipping fees based on package weight and track code length.

1  int charge = 0;
2  Console.Write("Enter your tracking code: ");
3  string trackCode = Console.ReadLine();
4  while (trackCode.Length < 6) {
5      string displayMessage = "is too short";
6      Console.Write(displayMessage);
7      trackCode = Console.ReadLine();
8  }
9  Console.Write("Enter package weight in kg: ");
10 int weight = Convert.ToInt32(Console.ReadLine());
11 if (weight < 5) {
12     charge = 3;
13 }
14 else {
15     charge = weight * 3;
16 }
17 Console.WriteLine(charge);

Figure 1

The charge for shipping packages weighing five or more kilograms is changed to include an additional £4 handling fee.

Rewrite line 15 in Figure 1 to show this change.

Your answer must be written in C#.

[1]

Arithmetic operations in a programming language Questions

Practise AQA GCSE Computer Science Arithmetic operations in a programming language with exam-style questions for GCSE Computer Science. 7 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

Next

Arithmetic operations in a programming language Questions

  1. GCSE
  2. /Computer Science
  3. /Arithmetic operations in a programming language