From dcf822d40ad17f51117731474cc4dbd68f2d8956 Mon Sep 17 00:00:00 2001 From: Matthew Strapp Date: Wed, 13 Feb 2019 16:03:32 -0600 Subject: Fix problem with negative time --- ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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; } +} -- cgit v1.2.3