Look, Im planning to make a payroll program using Turbo C++, i'm a beginner.
please help me or just give me steps on how to create my own program please?,,,,,

:confused: :confused::confused:

Dani AI

Generated

A concise, practical plan that builds on ’s class-based suggestion and keeps the first version small and testable:

Start by scoping the app: pick a pay period (weekly/monthly), list required inputs (employee id, name, rate, hours, deductions) and outputs (gross, each withholding, net). Split the program into four modules: data model, payroll calculator, storage/serialization, and a simple console UI. Keep tax rules and benefit rates in an external config file so the calculator code is purely arithmetic and easy to test.

A minimal C++ skeleton (focus: cents-as-integers to avoid float rounding):

#include <string>
#include <cstdint>

struct Money {
    int64_t cents;
    Money(long double amount = 0.0L) {
        if (amount >= 0) cents = static_cast<int64_t>(amount*100.0L + 0.5L);
        else cents = static_cast<int64_t>(amount*100.0L - 0.5L);
    }
    Money(int64_t rawCents, bool raw) : cents(rawCents) {}
    Money operator+(const Money& o) const { return Money(cents + o.cents, true); }
    Money operator-(const Money& o) const { return Money(cents - o.cents, true); }
    long double as_double() const { return cents / 100.0L; }
};

class Employee {
public:
    std::string id, name;
    Money hourlyRate;
    double hoursWorked;
};

class Payslip {
public:
    Employee emp;
    Money gross, tax, net;
    Payslip(const Employee& e);
    static Money computeTax(const Money& gross); // read rates from config
};

Persistence, rounding and debugging tips: store rows in CSV with a fixed header (escape commas in names) or a simple JSON if using a modern toolchain. Keep all monetary math in cents. Implement small unit tests for edge cases (0 hours, overtime, negative deductions). Log intermediate values when totals don't match. Make tax logic data-driven (brackets in a file), not hard-coded.

Note about tooling: Turbo C++ is old and limits modern C++ features; for easier development and learning, prefer a modern free toolchain (MinGW/Code::Blocks or Visual Studio). If stuck on Turbo, avoid C++11+ features and keep code very simple.

Recommended Answers

All 6 Replies

I think you have posted in wrong forum. please post this thread in C++ forum there are guys who can help you.

Oh.. Sorry, thats my first post..

You could start off by creating a class say 'Worker' which would represent specific data like name,weekly hours,untaxed wage etc.Then a class Payslip who's constructor takes a worker as an argument and applies taxes and subtracts social contributions emitting a list of all the operations being done and the total remaining wage.You can store everything in a file as comma separated values in the form of a string and provide an overload constructor for class Payslip which initializes an object by parsing a specific string retrieved from a file.Just write something down.

commented: thanks +0

Its ok... welcome to Daniweb :) happy coding

commented: thanks +0

Original post:

  1. moved to C++ section
  2. merged with double
  3. please do not advice on reposting in appropriate section, rather click Flag Bad Post and say "Please move to XYZ section" and a moderator will take care of it. We do not like to see double posted content

Thanks guys.. ^_^v..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.