I am a beginner to programming. I'm writing a C++ program that a user will their pay rate and the hours worked, and then calculate the pay and hours worked then display it. I finish the program the there are two errors that I tried to fix but I still can't figure out to fix it. The errors and my code is below. Can someone help me and tell me how to fix? I'm using MSVS Express 2013.
Errors:
Error 1 error C4700: uninitialized local variable 'hours'
Error 2 error C4700: uninitialized local variable 'rate'
(It is erroring on displayWeekly(rate, hours);
)
My Code:
#include "stdafx.h"
#include<iostream>
using namespace std;
void displayWeekly(double rate, int hours);
double getRate();
int getHours();
int main()
{
double rate;
int hours;
displayWeekly(rate, hours);
double getRate();
int getHours();
rate = getRate();
hours = getHours();
system("pause");
return 0;
}
void displayWeekly(double rate, int hours)
{
double weekPay;
weekPay = rate * hours;
cout << "Weekly pay is " << weekPay << endl;
}
double getRate()
{
double rate;
cout << "Enter your Hourly rate in the Dollars and Cents = ";
cin >> rate;
return rate;
}
int getHours()
{
int time;
cout << "Please Enter in the Hours you worked" << endl;
cout << "You must Enter a whole Number = ";
cin >> time;
return time;
}