Question

Hey, i was just wondering how i would calculate over time pay in c++ visual studio...

Hey, i was just wondering how i would calculate over time pay in c++ visual studio 2017? what i have right now is either returning 0 for some reason or being skipped over? im also wondering about the federal tax as well because that also doesn't seem to work, any help is greatly appreciated!

these are my variables

char chChoice = ' ';
int intempID = 0;
int intHours = 0;
int intOThours = 0;
float flOTrate = 0;
float flRate = 0;
float flGross = 0;
float flOTgross = 0;
float flGrosstotal = 0;
float flOASDI = 0.062;
float flMedicare = 0.0145;
float flFedtax = 0;
float flNet = 0;
double dblTotaltaxamount = 0;
float flTaxrate = 0;

int main()
{
   do
   {
       cout << "\n\t\t\tMenu" << endl;
       cout << "1) Enter employee data" << endl;
       cout << "2) Output" << endl;
       cout << "e) Exit" << endl;
       cin >> chChoice;

       system("cls");

       switch (chChoice)
       {
       case '1': //Input
           cout << "--Employee data entry--" << endl;
           cout << "Please enter the employees ID #: ";
           cin >> intempID;
           cout << "Please enter how many hours were worked: ";
           cin >> intHours;

           system("cls");
           //---------------------------
           //FIX OVERTIME PAY
           //---------------------------
           //HOURS REGULATOR
           while (intHours < 1 || intHours > 167)
           {
               cout << "Error: Hours must be greater than 0 and less than 168" << endl;
               cin >> intHours;
               if (intHours > 40)
               {
                   cout << "Overtime pay, yay for you!" << endl;
                   intOThours = intHours - 40;
                   flOTrate = flRate * 1.5;
                   flOTgross = flOTrate * intOThours;
               }

               system("cls");
           }
           //WAGE REGULATOR
           cout << "Please enter the rate of pay: ";
           cin >> flRate;
          
           while (flRate < 7.25)
           {
               cout << "ERROR: Unless the worker is a waiter/waitress this is illegal" << endl;
               cout << "Please enter the new hourly rate the employee will recieve" << endl;
               cin >> flRate;
           }

               //FED TAX RANGES
               if (flGross < 200)
               {
                   flFedtax = flGross * flTaxrate;
               }

               if (flGross > 200 || flGross < 500)
               {
                   flTaxrate = .15;
                   flFedtax = flGross * flTaxrate;
               }

               if (flGross > 500)
               {
                   flTaxrate = .21;
                   flFedtax = flGross * flTaxrate;
               }

               flGross = flRate * intHours;
               flGrosstotal = flGross + flOTgross;
              
               flOASDI = flGrosstotal * flOASDI;
               flMedicare = flGrosstotal * flMedicare;
               flNet = flGrosstotal - flOASDI - (flMedicare)-flFedtax;
              
               system("cls");
          
               break;

       case '2': //Output
           cout << "\t--Employee Tax Data-- ";
           cout << "********************************************************************" << endl;
           cout << "EmployeeID: " << intempID << endl;
           cout << "Hours Worked: " << intHours << endl;
           cout << "Overtime Hours: " << intOThours << endl;
           cout << "Rate of Pay: $" << flRate << endl;
           cout << "Overtime Rate: $" << flOTrate << endl;
           cout << "Gross Pay: $" << flGrosstotal << endl;
           cout << "FICA-OASDI Tax: $" << flOASDI << endl;
           cout << "FICA-Medicare: $" << flMedicare << endl;
           cout << "Federal Tax: $" << flFedtax << endl;
           cout << "Net Pay: $" << flNet <<endl;
           cout << "********************************************************************" << endl;

       case 'E':
       case 'e': //Exit
           break;

       default:
           cout << "pick a different option" << endl;
           system("pause");
           break;
       }
   } while (chChoice != 'E' && chChoice != 'e');
   return 0;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

#include <fstream>

using namespace std;

char chChoice = ' ';

int intempID = 0;

int intHours = 0;

int intOThours = 0;

float flOTrate = 0;

float flRate = 0;

float flGross = 0;

float flOTgross = 0;

float flGrosstotal = 0;

float flOASDI = 0.062;

float flMedicare = 0.0145;

float flFedtax = 0;

float flNet = 0;

double dblTotaltaxamount = 0;

float flTaxrate = 0;

int main()

{

do

{

cout << "\n\t\t\tMenu" << endl;

cout << "1) Enter employee data" << endl;

cout << "2) Output" << endl;

cout << "e) Exit" << endl;

cin >> chChoice;

system("cls");

switch (chChoice)

{

case '1': //Input

cout << "--Employee data entry--" << endl;

cout << "Please enter the employees ID #: ";

cin >> intempID;

cout << "Please enter how many hours were worked: ";

cin >> intHours;

system("cls");

//---------------------------

//FIX OVERTIME PAY

//---------------------------

//HOURS REGULATOR

while (intHours < 1 || intHours > 167)

{

cout << "Error: Hours must be greater than 0 and less than 168" << endl;

cin >> intHours;

system("cls");

}

//WAGE REGULATOR

cout << "Please enter the rate of pay: ";

cin >> flRate;

if (intHours > 40)

{

cout << "Overtime pay, yay for you!" << endl;

intOThours = intHours - 40;

flOTrate = flRate * 1.5;

flOTgross = flOTrate * intOThours;

}

while (flRate < 7.25)

{

cout << "ERROR: Unless the worker is a waiter/waitress this is illegal" << endl;

cout << "Please enter the new hourly rate the employee will recieve" << endl;

cin >> flRate;

}

flGross = flRate * intHours;

//FED TAX RANGES

if (flGross < 200)

{

flFedtax = flGross * flTaxrate;

}

if (flGross > 200 || flGross < 500)

{

flTaxrate = .15;

flFedtax = flGross * flTaxrate;

}

if (flGross > 500)

{

flTaxrate = .21;

flFedtax = flGross * flTaxrate;

}

flGrosstotal = flGross + flOTgross;

flOASDI = flGrosstotal * flOASDI;

flMedicare = flGrosstotal * flMedicare;

flNet = flGrosstotal - flOASDI - (flMedicare)-flFedtax;

system("cls");

break;

case '2': //Output

cout << "\t--Employee Tax Data-- ";

cout << "********************************************************************" << endl;

cout << "EmployeeID: " << intempID << endl;

cout << "Hours Worked: " << intHours << endl;

cout << "Overtime Hours: " << intOThours << endl;

cout << "Rate of Pay: $" << flRate << endl;

cout << "Overtime Rate: $" << flOTrate << endl;

cout << "Gross Pay: $" << flGrosstotal << endl;

cout << "FICA-OASDI Tax: $" << flOASDI << endl;

cout << "FICA-Medicare: $" << flMedicare << endl;

cout << "Federal Tax: $" << flFedtax << endl;

cout << "Net Pay: $" << flNet <<endl;

cout << "********************************************************************" << endl;

case 'E':

case 'e': //Exit

break;

default:

cout << "pick a different option" << endl;

system("pause");

break;

}

} while (chChoice != 'E' && chChoice != 'e');

return 0;


}

============
SEE OUTPUT

saved main.cpp https://DefiniteTrimCurrencies.rahulkumar29.L 47 sh: 1: cls: not found 48 cout << Error: Hours must be greate
Thanks, PLEASE COMMENT if there is any concern.

Add a comment
Know the answer?
Add Answer to:
Hey, i was just wondering how i would calculate over time pay in c++ visual studio...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hey, so i am trying to have my program read a text file using a structure...

    Hey, so i am trying to have my program read a text file using a structure but i also want to be able to modify the results(I kinda have this part but it could be better). I cant seem to get it to read the file(all the values come up as 0 and i'm not sure why because in my other program where it wrote to the txt file the values are on the txt file) i copied and pasted...

  • This question is about calculating and printing payslips. User inputs his name, number of worked hours...

    This question is about calculating and printing payslips. User inputs his name, number of worked hours and hourly rate. below is the source file for my program...It's supposed calculate salaries. Given that a work week has 40 hours and over time is 1.5xnormalRate for each our of overtime My output is not working. what is wrong with this code? // Calculate and print payslips #include <iostream> #include <iomanip> using namespace std; const float workingHours = 40.0; void getData( string &employeeP,...

  • Why is my code not calculating the pay and not printing entire data at the end? // // main.cpp // Project 14 // // Created by Esmeralda Martinez on 5/13/19. // Copyright © 2019 Esmeralda Martinez. All...

    Why is my code not calculating the pay and not printing entire data at the end? // // main.cpp // Project 14 // // Created by Esmeralda Martinez on 5/13/19. // Copyright © 2019 Esmeralda Martinez. All rights reserved. // #include<iostream> #include<fstream> #include<cstdlib> #include<regex> #include <iomanip> using namespace std; float grossPay(float hrsWorked, float payrate); float grossPay(float hrsWorked, float payrate){ return hrsWorked*payrate;       } int main(){    //opening an output file ifstream outFile("Employee.txt", ios::in); //Read variables string depId,emp_num,firstName,lastName,email,hrs_worked,pay_rate,ch="y";    //Regex patterns regex integerPattern("(\\+|-)?[[:digit:]]+"); regex...

  • Hello i am having a bit of trouble with a verified exit for my program. For...

    Hello i am having a bit of trouble with a verified exit for my program. For some reason when trying to exit it loops to the team selection function? C++ Visual Studio 2017 #include "cPlayer.h" char chChoice1 = ' '; char chChoice3 = ' '; cPlayer::cPlayer() { } cPlayer::~cPlayer() { } void cPlayer::fMenu() {    char chChoice3 = ' ';    do    {        cout << "\n\t--Menu--" << endl;        cout << "1) Enter Player Name" <<...

  • Code is in C++: Im wondering how i can make the program continue to ask the...

    Code is in C++: Im wondering how i can make the program continue to ask the user to enter Y/N with the if statment. Is it possible with an If statment? #include <iostream> using namespace std; int main() { float usDollars,cYuan; float *Dollars; char choice; Dollars = &usDollars; while(usDollars >= 0){ cout <<"Enter the amount in U.S Dollars: "; cin >> usDollars; cout << usDollars<< " U.S Dollar in Chinese Yuan is :"<<*Dollars*7.09<<endl; if (choice == 'y' || choice ==...

  • C++ programming I need at least three test cases for the program and at least one...

    C++ programming I need at least three test cases for the program and at least one test has to pass #include <iostream> #include <string> #include <cmath> #include <iomanip> using namespace std; void temperatureCoverter(float cel){ float f = ((cel*9.0)/5.0)+32; cout <<cel<<"C is equivalent to "<<round(f)<<"F"<<endl; } void distanceConverter(float km){ float miles = km * 0.6; cout<<km<<" km is equivalent to "<<fixed<<setprecision(2)<<miles<<" miles"<<endl; } void weightConverter(float kg){ float pounds=kg*2.2; cout<<kg<<" kg is equivalent to "<<fixed<<setprecision(1)<<pounds<<" pounds"<<endl; } int main() { string country;...

  • Trying to figure out how to complete my fourth case 4 (option exit), write a function...

    Trying to figure out how to complete my fourth case 4 (option exit), write a function that display a “Good Bye” message and exits/log out from user’s account displaying a menu (sign in, balance, withdraw and exit.. #include<iostream> #include <limits> using namespace std; void printstar(char ch , int n); double balance1; int main() { system("color A0"); cout<<"\n\t\t ========================================="<< endl; cout<<"\t\t || VASQUEZ ATM SERVICES ||"<< endl; cout<<"\t\t ========================================\n\n"<< endl; int password; int pincode ; cout<<" USERS \n"; cout<<" [1] -...

  • C++ getline errors I am getting getline is undefined error messages. I would like the variables...

    C++ getline errors I am getting getline is undefined error messages. I would like the variables to remain as strings. Below is my code. #include <iostream> #include<string.h> using namespace std; int index = 0; // variable to hold how many customers are entered struct Address //Structure for the address. { int street; int city; int state; int zipcode; }; // Customer structure struct Customer { string firstNm, lastNm; Address busAddr, homeAddr; }; // Functions int displayMenu(); Customer getCustomer(); void showCustomer(Customer);...

  • C++ EXERCISE (DATA STRUCTURES). I just need a code for some functions that are missing. Please...

    C++ EXERCISE (DATA STRUCTURES). I just need a code for some functions that are missing. Please help me figure out. Thanks. C++ BST implementation (using a struct) Enter the code below, and then compile and run the program. After the program runs successfully, add the following functions: postorder() This function is similar to the inorder() and preorder() functions, but demonstrates postorder tree traversal. displayParentsWithTwo() This function is similar to the displayParents WithOne() function, but displays nodes having only two children....

  • Convert to use functions where possible #include<iostream> #include<string> using namespace std; int main() {    string...

    Convert to use functions where possible #include<iostream> #include<string> using namespace std; int main() {    string first, last, job;    double hours, wages, net, gross, tax, taxrate = .40;    double oPay, oHours;    int deductions;    // input section    cout << "Enter First Name: ";    cin >> first;    cout << "Enter Last Name: ";    cin >> last;    cin.ignore();    cout << "Enter Job Title: ";    getline(cin, job);    cout << "Enter Hours Worked:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT