aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp b/ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp
index 5e3e95c..b261664 100644
--- a/ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp
+++ b/ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp
@@ -18,6 +18,11 @@ int main () {
double SocSec, State, Fed, GrossPay, NetPay;
cout << "How many hours did you work this week?: ";
cin >> Hours;
+ if (Hours < 0) {
+ cout << "Invalid option!" << endl;
+ return 2;
+ }
+ else{
cout << "How many dependents do you have?: ";
cin >> Dependents;
if (Hours > 40) { //Every hour over 40 constitutes as overtime
@@ -43,3 +48,4 @@ int main () {
<< "Your net (after witholdings) pay is $" << NetPay << "." << endl;
}
+}