Skip to content

Course home

Arithmetic operations in a programming language

Arithmetic operations in a programming language

EasyMedium
12345
Question 3

A C# program calculates the daily rental rate of a scooter based on the state code and rental duration.

1  int rate = 0;
2  Console.Write("Enter driver license state code: ");
3  string stateCode = Console.ReadLine();
4  while (stateCode.Length != 2) {
5      string promptMessage = "Must be 2 letters: ";
6      Console.Write(promptMessage);
7      stateCode = Console.ReadLine();
8  }
9  Console.Write("Enter rental duration in hours: ");
10 int hours = Convert.ToInt32(Console.ReadLine());
11 if (hours < 3) {
12     rate = 12;
13 }
14 else {
15     rate = hours * 4;
16 }
17 Console.WriteLine(rate);

The rate for rentals lasting three or more hours is changed to include an additional £5 safety insurance surcharge.

Rewrite line 15 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