This is a question I'm stuck with from the book "C++ Programming 101" :
Write a program that computes net pay based on the values the user types, Ask the user for the hours worked, the rate per hour, and the tax rate. Because most employees work 40 hours per week and earn $5.00 per hour, use these values as default values in the function that computes the net pay. If the user presses Enter in response to your questions, use the default values.
Here is what I got so far: I don't know what to do with the Enter.. How do I do that if the user presses Enter the default values will be sent?
Code:
#include <iostream>
using namespace std;
float compute_net(float tax, int hours = 40, int rate = 5); //prototype
main()
{
int hours;
int rate;
float tax;
float ans;
cout << "How many hours did you work? \n";
cin >> hours;
cout << "How much do you make per hour? \n";
cin >> rate;
cout << "How much tax do you pay? \n";
cin >> tax;
ans = compute_net(tax, hours, rate);
cout << ans;
return 0;
}
float compute_net(float tax, int hours, int rate)
{
float net;
net= (hours*rate) - (hours*tax);
return(net);
}