Build a PaymentProcessor Interface

Hard Virtual Functions & Abstract Classes PRO
🔒 Login to Unlock

Problem Statement

Combine the concepts! Design an abstract interface `PaymentProcessor` with a pure virtual `void process(float amt)`. Derive `CreditCard` processing to print ‘CC: [amt]’ and `PayPal` printing ‘PayPal: [amt]’. Read a float `amt` from input. Instantiate both systems and process the amount via base class pointers.

Input Format

A single float value.

Output Format

Print the specific processor output on separate lines.

Constraints

None

Sample Input

150.5

Sample Output

CC: 150.5
PayPal: 150.5

Explanation

Interfaces dictate a required set of behaviors. Any class conforming to the `PaymentProcessor` interface guarantees it can process amounts safely.

Starter Code

#include <iostream>

class PaymentProcessor {
public:
    // Pure virtual function
};

class CreditCard : public PaymentProcessor {
public:
    // Implementation
};

class PayPal : public PaymentProcessor {
public:
    // Implementation
};

int main() {
    // Read input and process via base pointers
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used