Practice

Rope Cost Calculator

2023/Oct/Nov·Variant 1
MEDIUMSelection

Calculate the cost of a length of rope. Read the length (between 0.5 and 6.0 inclusive), validate it with a WHILE loop, then read the cost per metre. Output the total price.

Input: First the length (re-input until valid), then the cost per metre. Output: The calculated price (numeric value only).

Example:

Input:  8.0
        0.4
        2.5
        2.0
Output: 5
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: Valid on first try
Inputs: 2.5, 2.0
Expected: 5
Test 2: Invalid then valid
Inputs: 7.0, 0.2, 3.0, 1.5
Expected: 4.5
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade