diff options
author | Matthew Strapp <msattr@gmail.com> | 2019-02-13 16:03:32 -0600 |
---|---|---|
committer | Matthew Strapp <msattr@gmail.com> | 2019-02-13 16:03:32 -0600 |
commit | dcf822d40ad17f51117731474cc4dbd68f2d8956 (patch) | |
tree | 17c83fd4dfd2af307f8edde3ad9f853597f74249 /ee1301 | |
parent | Fix problems mk. 200 (diff) | |
download | homework-dcf822d40ad17f51117731474cc4dbd68f2d8956.tar homework-dcf822d40ad17f51117731474cc4dbd68f2d8956.tar.gz homework-dcf822d40ad17f51117731474cc4dbd68f2d8956.tar.bz2 homework-dcf822d40ad17f51117731474cc4dbd68f2d8956.tar.lz homework-dcf822d40ad17f51117731474cc4dbd68f2d8956.tar.xz homework-dcf822d40ad17f51117731474cc4dbd68f2d8956.tar.zst homework-dcf822d40ad17f51117731474cc4dbd68f2d8956.zip |
Fix problem with negative time
Diffstat (limited to '')
-rw-r--r-- | ee1301/wk2/lab2/strap012_lab2_pay_stub.cpp | 6 |
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; } +} |