Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Develop code

EasyMediumHard
123456789101112
Question 5

A program is needed to create a unique passcode for a logistics database.

A user enters a three-letter location code, a whole number representing a zone, and a decimal number representing weight.

The program must validate the location code to ensure it is exactly three characters long.

If the location code is not exactly three characters long, the program must display an error message.

If it is valid, a passcode is generated by combining:

  1. The reversed location code
  2. The whole number part of the decimal weight
  3. The zone number

Figure 1 shows example input values and the resulting passcode.

Enter location code: NYC
Enter zone number: 4096
Enter package weight: 12.85
Generated passcode: CYN124096

Write a program to solve this problem.

[8]

Develop code Questions

  1. IGCSE
  2. /Computer Science
  3. /Develop code