Click here to Skip to main content
14,699,605 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <conio.h>
#include <windows.h>
using namespace std;


 void textcolor(int color);
 struct payroll
 {
     string name;
     float rate_per_day,sss,philhealth;
     int total_days_work;
 };


  float compute_gross(float rate_per_day, float days_worked)
  {
      return(rate_per_day * days_worked);
  }
float compute_net(float rate_per_day,
                 float days_worked,
                 float sss,float philhealth)
 {
     float gross_pay=0.00, deductions=0.00, net_income=0.00;
     gross_pay = (rate_per_day * days_worked);
     deductions = (sss+philhealth);
     net_income = (gross_pay - deductions);
     return(net_income);
 }

float compute_deductions(float sss,float philhealth)
 {
       return(sss+philhealth);
 }

the main method.

 main()
 {
    payroll employee;
    cout << "\t Simple Payroll System ";
    cout << "\n\n";
    cout << " Enter Employees Name         : ";
    getline(cin,employee.name);
    cout << " Enter Employees Rate/Day     : ";
    cin >> employee.rate_per_day;
    cout << " Enter Number of Days Worked  : ";
    cin >> employee.total_days_work;
    cout << "\n\n";
    cout <<  "  == DEDUCTIONS == ";
    cout << "\n\n";
    cout << "\nSSS Contribution          : ";
    cin >> employee.sss;
    cout << "PhilHealth Contribution   : ";
    cin >> employee.philhealth;
    cout << "\n\n";
    cout << fixed << setprecision(2);
    cout << "  Total Deductions =>  Php "
         << compute_deductions(employee.sss,
            employee.philhealth);
    cout << "\n";
    cout << "  Monthly Gross Income : Php " <<
            compute_gross(employee.rate_per_day,
            employee.total_days_work);
    cout << "\n\n";
    cout << "\n Employees Name     : " << employee.name;
    cout << "\n Monthly Net Income : Php " <<
            compute_net(employee.rate_per_day,
            employee.total_days_work,
            employee.sss,employee.philhealth);
    cout << "\n\n";
    system("pause");
}


What I have tried:

&lI have tried different ways but I'm struggling right now.
Posted
Updated 29-Oct-20 1:44am
v3

1 solution

No need to struggle: you have just to replace C++ streams cin/cout/getline with correpsonding C I/O function calls (e.g. printf/scanf/fgets), no rocket science, really.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900