Question:

C++ programing help?

by  |  earlier

0 LIKES UnLike

Why won't this program execute?

#include <iostream>

#include <iomanip>

using namespace std;

int main ()

{

// Global variables

double hours, pay_rate, regular_pay;

double overtime_pay, Gross_Pay, Net_Pay;

double tax = .055;

// The functions receive no parameters and return no results.

// All communication is through the global variables.

void Calculate_Gross_Pay();

void Calculate_tax();

void Calculate_Net_Pay();

void Display_Results();

cout << setprecision(2)

<< setiosflags(ios::fixed)

<< setiosflags(ios::showpoint);

do

{

cout << "Enter the person's pay rate: ";

cin >> pay_rate;

cout << "Enter the person's number of hours worked: ";

cin >> hours;

void Calculate_Gross_Pay();

if (hours > 40.0)

{

regular_pay = hours * pay_rate;

overtime_pay = (hours - 40.0) * 1.5 * pay_rate;

}

else

{

regular_pay = hours * pay_rate;

overtime_pay = 0.00;

}

Gross_Pay = regular_pay + overtime_pay;

//Calculate Tax

tax = tax * Gross_Pay;

//Calculate net pay

Net_Pay = Gross_Pay - tax;

//Display results

cout << endl << endl;

cout << "Regular Pay: " << setw(7) << regular_pay << endl;

cout << "Tax: " << setw(7) << tax << endl;

cout << "Gross Pay: " << setw(7) << Gross_Pay << endl;

cout << "--------------------" << endl;

cout << "Net Pay: " << setw(7) << Net_Pay << endl;

}

return 0;

}

 Tags:

   Report

3 ANSWERS


  1. It would help if you included the errors the compiler is throwing at you.

    But right off the bat, your first two lines must be:

    #include &lt;iostream.h&gt;

    #include &lt;iomanip.h&gt;

    Not including the &quot;.h&quot; could be causing compile errors.  See how that goes.


  2. I put it into my Dev C++ comiler:

    There&#039;s no while to go along with that do

    I added a

    while(true)

    right before the return 0;  and if worked just fine.

  3. You give 3 function prototypes for calculations and 1 for the display, but you never call any of the functions.  And you have another function prototype for Calculate_Gross_Pay stuck in the middle of your do loop, which makes no sense.

    Also, where&#039;s &quot;while&quot; delimiter portion of the do loop?  You need to ask a question like &quot;do you want to continue&quot; and have the answer be the condition.
You're reading: C++ programing help?

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.