Help Please

Create a program that displays the weekly gross pay for any number of employees. The user will input the number of hours the employee worked and the employee’s hourly rate. Employees working more than 40 hours receive time and one-half for the hours worked over 40. If necessary, create a new project named Introductory18 Project, and save it in the Cpp8\Chap07 folder. Enter the C++ instructions into a source file named Introductory18.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Save, run, and test the program.


When I make a program I keep on getting a error. Can someone help me create a running c++ program.
What IDE (Integrated Development Environment) are you using? Example: Visual Studio
Can you post your current broken code you have?
//displays the weekly gross pay for any employee

#include <iostream>
using namespace std;

int main()
{
std::cout << "\nHourly workers pay:\n";
//Get hourly rate

std::cout << "Hourly rate: $";
double rate;
std::cin >> rate;
//Get hours worked

std::cout << "Hours worked: ";
double hours;
std::cin >> hours;

//calculate pay
double pay;

//check for overtime
if(hours > 40.0)

{
//standard rate
pay += rate * 40;

//overtime rate
pay += (rate * 1.5) * (hours - 40);
}

else
pay += rate * hours;

//results
if(std::cin.good())
std::cout << "The hourly workers pay is: $" << pay << "\n" << std::endl;
return 0;
}


I keep getting this code and a error.

1>------ Build started: Project: Introductory 18 Project, Configuration: Debug Win32 ------
1> Introductory18.cpp
1>c:\cpp8\chap 07\introductory 18 project\introductory 18 project\introductory18.cpp(30): warning C4700: uninitialized local variable 'pay' used
1> Introductory 18 Project.vcxproj -> C:\Cpp8\Chap 07\Introductory 18 Project\Debug\Introductory 18 Project.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
I do not know how to fix this code. Any suggestions on how I can get it too debug. Or if there is a better code. I am using Microsoft Visual Studio Express 2012
Last edited on
you need to initialize the variable pay.

1
2
	//calculate pay
	double pay = 0;
Last edited on
Thank You!
Topic archived. No new replies allowed.