Two-Wheeler and Four-Wheeler Production (Scenario-Based)
E · easyP · Verified PYQmath
Problem
An automobile company manufactures both two-wheelers (TW) and four-wheelers (FW). Given: - Total number of vehicles (TW + FW) = V - Total number of wheels = W Find how many two-wheelers and four-wheelers need to be manufactured. Print “INVALID INPUT” if the inputs don’t satisfy valid constraints (e.g. negative counts). Formula: TW + FW = V and 2TW + 4FW = W Solve: FW = (W - 2V) / 2, TW = V - FW
Constraints
V > 0, W > 0, W must be even, FW and TW must be non-negative integers
Example
Input
12 32
Output
TW = 8 FW = 4
Check: if (W-2V) is negative or odd or FW > V → print INVALID INPUT.
FW=(32-24)/2=4, TW=12-4=8. Verify: 8+4=12 vehicles, 16+16=32 wheels. Correct!