Skip to content

Course home

Arithmetic operations in a programming language

Arithmetic operations in a programming language

EasyMedium
12345
Question 5

A C# program calculates monthly cloud storage fees based on a user's member ID length and storage usage in gigabytes (GB).

1  int bill = 0;
2  Console.Write("Enter your member ID: ");
3  string memberId = Console.ReadLine();
4  while (memberId.Length < 8) {
5      string displayMessage = "ID too short";
6      Console.Write(displayMessage);
7      memberId = Console.ReadLine();
8  }
9  Console.Write("Enter storage used in GB: ");
10 int storage = Convert.ToInt32(Console.ReadLine());
11 if (storage < 10) {
12     bill = 5;
13 }
14 else {
15     bill = storage * 2;
16 }
17 Console.WriteLine(bill);

Figure 1

The monthly fee for users with 10 or more gigabytes of storage is changed to include an additional £6 maintenance surcharge, and the rate per gigabyte is increased from £2 to £5.

Rewrite line 15 in Figure 1 to show this change.

Your answer must be written in C#.

[1]
Markscheme

Arithmetic operations in a programming language Questions

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

7 exam-style questions on AQA GCSE Computer Science Arithmetic operations in a programming language. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank