Hi everyone! I'm both new here, and new to programming. I'm still learning how it all fits together, and have been putting together a simple assignment, but I've gotten a little stuck, and so far the book hasn't been a help. I know it must be something simple, but for the life of me I can't see it. The program compiles just fine, but when I run it, it stops asking people to put in the info, and crashes out. Anyway, here it is, if you could take a look and maybe point me in the right direction, I'd appreciate it.

#include <iostream>

using namespace std ;

int main()

{

    int employeeID ;//Name of employee
    float hourlyRate ;//Rate of pay per hour
	float regularHours ;//Regular number of hours worked
	float overtimeHours ;//Overtime hours worked
	float grossPay ;//Total pay before taxes
    float regularHourWages ;//How much was made in regular hours
	float overTimeHourWages ;//How much was made working overtime

    // greeting and read in employee ID

    cout << endl ;
    cout << "A-Z Supermarket Employees Monthly Gross Pay Calculation." ;
	cout << endl ;
	cout <<	"Enter Employee ID: " ; 
    cin >> employeeID ;

    // read in the hourly rate

    cout << endl ;
	cout << "Enter hourly pay rate (specify two digits "
         << "after the decimal point):" ;
    cin >> hourlyRate ;

	// read in regular hours worked

	cout << endl ;
	cout << "Enter Regular Hours worked: " ;
	cin >> regularHours ;

	// read in overtime hours
	
	cout << endl ;
	cout << "Enter Overtime Hours worked: " ;
	cin >> overtimeHours ;

    // compute wages

    regularHourWages = hourlyRate * regularHours ;
	overTimeHourWages = 1.5 * hourlyRate * overtimeHours ;
	grossPay = regularHourWages + overTimeHourWages ;

    // display the result

    cout << endl ;
    cout << "Regular Hours Worked: " << +regularHours   ;
	cout << "Overtime Hours Worked: " << +overtimeHours ;
	cout << "Gross Pay for Employee" << +employeeID+ "is" <<+grossPay << endl;

    return (0); // terminate with success

}

The problem that really stands out for me is your output area.

You are using cout << "text" << +a; and cout << "text" << +a+ "moretext" << +b << endl; When using cout only use + for adding numbers together.
For output you just need to go cout << "text" << a << "moretext" << b << endl;

This is C++ and it is different from C#. You use the symbol '<<' to redirect your stream to the intended output. For example, to output the regular hours is simply:

cout << "Regular Hours Worked: " << regularHours << endl; // you would want an end of line here to separate it from the next statement

Equally, this is done in C# using:

Console.Writeline("Regular Horus Worked: " + regularHours);

Hope this helps...

also, this is prettier

cout << endl
<< "Regular Hours Worked: " << regularHours
<< "Overtime Hours Worked: " << overtimeHours
<< "Gross Pay for Employee" << employeeID << "is" << grossPay << endl;
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.