Can someone please help me with this code? I have already taken out some of the errors, and my instructor says to make sure my brackets are enclosed. When I do this though I get more errors???Help!!!

#include <io>
#include <string>
#include <iomanip>

using namespace std;

//Global Declarations of Variables

double iovertime_hours=0, iovertime pay=0, iovertime_extra=0;
int ihours, iwage ;
string cname ;

int main ()
{
    //Enter Employee Information
    cout << "\n\nEnter the employee name = ";
    cin >> cname ;
    cout << "Enter the hours worked  = ";
    cin >> ihours;
    cout << "Enter his or her hourly wage = ";
    cin >> iwage; 

    // Determine if hours are greater than 40 

    if (ihours < 40) 
    {
        //Do Calculations
        iovertime_hours=ihours+40;
        iovertime_pay=iwage-1.5 ;
        iovertime_extra=iovertime_hours*iovertime_pay;

        / Display Employee Details
        cout >> "\n\n";
        cout << "Employee Name ............. = ' << cname << endl" ;
        cout << "Base Pay .................. = " << iwage*40 << endl; 
        cout << "Hours in Overtime ......... = " << iovertime_hours << endl ;
        cout << "Overtime Pay Amout......... = " << iovertime_extra << endl ;
        cout << "Total Pay ................. = " << iovertime_extra+(40*iwage) << endl ;
    }    
    else // Else hours are less than 40 hours
    {
        cout << "\n\n";
        cout << "Employee Name ............. = " << cname << endl ;
        cout << "Base Pay .................. = " << iwage*40 << endl ;
        cout << "Hours in Overtime ......... = " << iovertime_hours << endl ;
        cout << "Overtime Pay Amout......... = " << iovertime_extra << endl ;
        cout << "Total Pay ................. = " << iovertime_extra+(40*iwage) << endl;
    } // End of the primary if statement 

} //End of Int Main

Recommended Answers

All 7 Replies

compare your code to mine should fix most your erros

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

//Global Declarations of Variables

double iovertime_hours=0; 
double iovertime_pay=0; 
double iovertime_extra=0;
int ihours, iwage ;
string cname ;

int main ()
{
//Enter Employee Information
cout << "\n\nEnter the employee name = ";
cin >> cname ;
cout << "Enter the hours worked = ";
cin >> ihours;
cout << "Enter his or her hourly wage = ";
cin >> iwage;

// Determine if hours are greater than 40

if (ihours < 40)
{
//Do Calculations
iovertime_hours=ihours+40;
iovertime_pay=iwage-1.5 ;
iovertime_extra=iovertime_hours*iovertime_pay;

// Display Employee Details
cout << "\n\n";
cout << "Employee Name ............. = " << cname << endl;
cout << "Base Pay .................. = " << iwage*40 << endl;
cout << "Hours in Overtime ......... = " << iovertime_hours << endl ;
cout << "Overtime Pay Amout......... = " << iovertime_extra << endl ;
cout << "Total Pay ................. = " << iovertime_extra+(40*iwage) << endl ;
}
else // Else hours are less than 40 hours
{
cout << "\n\n";
cout << "Employee Name ............. = " << cname << endl ;
cout << "Base Pay .................. = " << iwage*40 << endl ;
cout << "Hours in Overtime ......... = " << iovertime_hours << endl ;
cout << "Overtime Pay Amout......... = " << iovertime_extra << endl ;
cout << "Total Pay ................. = " << iovertime_extra+(40*iwage) << endl;
} // End of the primary if statement

} //End of Int Main

also next time please use the code tags

Sorry it would not let me tag the problem. I ran your code in C++ and it is still coming up with errors and will not build:

1>------ Build started: Project: Overtime Pay, Configuration: Debug Win32 ------
1> Overtime Pay.cpp
1>c:\users\johnny\documents\visual studio 2010\projects\overtime pay\overtime pay\overtime pay.cpp(1): warning C4067: unexpected tokens following preprocessor directive - expected a newline
1>c:\users\johnny\documents\visual studio 2010\projects\overtime pay\overtime pay\overtime pay.cpp(1): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\johnny\documents\visual studio 2010\projects\overtime pay\overtime pay\overtime pay.cpp(2): warning C4627: '#include <string>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\johnny\documents\visual studio 2010\projects\overtime pay\overtime pay\overtime pay.cpp(3): warning C4627: '#include <iomanip>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\johnny\documents\visual studio 2010\projects\overtime pay\overtime pay\overtime pay.cpp(53): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

try adding this to the top of your code

#include 'StdAfx.h'

When I put that in it says Error: expected a file name

my bad double quotes and the capital letters dont matter for that

#include "stdafx.h"

your first line should be #include <iostream>

Some of your logic is wrong.
Overtime hour is anything over 40 hours
That means if the person made 50 hours then overtime hours is 10 hours.
So iovertime_hours=ihours-40

Same with your overtime pay. Overtime pay is the wage * 1.5

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.