Employee Class

Easy Classes & Objects
Solve in Playground →

Problem Statement

Write a C++ program defining an `Employee` class that computes annual salary based on monthly salary input and displays the record.

Input Format

ID (int), Name (string), and Monthly Salary (double).

Output Format

Print employee ID, name, and calculated annual salary.

Constraints

Monthly Salary >= 0

Sample Input

5001 Manager 50000.0

Sample Output

ID: 5001, Name: Manager, Annual Salary: 600000.00

Explanation

Calculates derived values using class methods.

Starter Code

#include <iostream>
#include <string>
#include <iomanip>

class Employee {
public:
    int id;
    std::string name;
    double monthlySalary;
    
    void displayAnnual() {
        // Write your code here
    }
};

int main() {
    Employee e;
    if (std::cin >> e.id >> e.name >> e.monthlySalary) {
        e.displayAnnual();
    }
    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