Hello, I'm a beginner in this site. I was just hoping that someone might be able to answer my question regarding to debugging a payroll.
Here:
#include <iostream>
#include <conio.h>
#include <string>
#include <windows.h>
#include <stdio.h>
using namespace std;
const string userName= "Username"; //assigns the username
const string passWord= "Password"; //assigns the password
int main()
{
cout << "\n\t\t Welcome To Your Payroll Account!" <<endl;
cout << "\t\t Please Enter Your Username & Password To Proceed. " <<endl;
cout << "\t *********************************************************" <<endl;
string pass[10];
string name;
string month,Ename,address;
float regpay, regov, RD, RDOT, meal;
float SSS, PH, PI, Union, other, SSSsal, Loan, Hloan, ULoan, ELoan, TD;
float TE,Netpay;
int n,day,year;
char input;
char again = 'Y';
while (again =='Y' || again =='y') //creates the loop for test condition
{
cout << "\nUsername: "; //prompt user
cin >> name; //inputs name
cout << "Password: "; //prompt user
for(int i=1;i<10;i++)
{
pass[i]=_getch();
cout<<"*";
passWord == pass[i];
}
if (name == userName && passWord == passWord) // Executes the statements if condition is TRUE
cout << "\n \n You are logged in!"
<< "\n Enter '#' to proceed: "; //Output if the condition is TRUE
else // Executes the statements if another condition is TRUE or FALSE
cout << "\n Incorrect username or password. \a"
<< "\n \n Do you want to try again? Yes(Y)/No(N) "
<< "\n \n Continue? "; // prompt user
cin >> again; // inputs looping
}
while (again == 'y' || again == 'Y')
{
if(again == 'N' || again == 'N');
goto stop;
}
{
{
cout<<"\n Enter '#' again to Proceed to your Payslip: ";
cin>>input;
if (input == '#');
{
cout <<" " <<endl;
cout << "\nMonth: " ;
cin >> month;
cout << "Day: ";
cin >> day;
cout << "Year: ";
cin >> year;
cout << "\n\n EMPLOYEE'S NAME: ";
cin >> Ename;
cout << "EMPLOYEE'S ADDRESS: ";// Starting at this point the program terminates and giving negative values result on the payroll.
cin >> address;
cout << "REGULAR PAY: ";
cin >> regpay;
cout << "REST DAY: ";
cin >>RD;
cout << "REGULAR OVERTIME: ";
cin >> regov;
cout << "RESTDAY OT: ";
cin >> RDOT;
cout << "MEAL ALLOWANCE:";
cin >> meal;
cout <<"SSS: ";
cin >>SSS;
cout << "PhilHealth: ";
cin >>PH;
cout << "PAG-IBIG: ";
cin >>PI;
cout << "Union Dues: ";
cin >>Union;
cout << "Other Deductions: ";
cin >>other;
cout << "\n\t\t\t Nutri Snack Food Corp." <<endl;
cout << "\n\t\t\t Gen. Luis St. Novaliches, Q.C." <<endl;
cout << "\n\t*************************************************************** " << endl;
cout << "\n\t\t\t Payslip for: " <<month <<"-" <<day <<"-" <<year <<endl;
cout << "\n\t*************************************************************** " << endl;
cout << "\n\t Name: " <<Ename <<endl;
cout << "\t Address: " <<address <<endl;
cout << "\n ======== EARNINGS ========" << "\t\t\t ======== DEDUCTIONS =======" <<endl;
cout << " Regular Pay = " <<regpay << "\t\t\t\t SSS = " <<SSS <<endl;
cout << " Regular OT = " <<regov << "\t\t\t\t PhilHealth = " <<PH <<endl;
cout << " Rest Day = " <<RD << "\t\t\t\t PAG-IBIG = " << PI <<endl;
cout << " Rest Day OT = " <<RDOT << "\t\t\t\t Union Dues: " << Union <<endl;
cout << " Meal Allowance = " <<meal << "\t\t\t\t Other Deductions: " <<other <<endl;
TD =(SSS+PH+PI+Union+other);
TE = (regpay+regov+RD+RDOT+meal);
Netpay = TE-TD;
cout << "\n\t\t ===========================================" <<endl;
cout << "\t\t TOTAL DEDUCTION: " << TD << " TOTAL EARNINGS: " <<TE <<endl;
cout << "\t\t ===========================================" <<endl;
cout << "\t\t\t\t NETPAY: " <<Netpay <<endl;
stop:
_getch();
system ("pause");
return 0;
}
}
}
}
I was thinking that the formula given as already right but it keeps on terminating the wrong way. I appreciate suggestions in helping to debug this.