Modify the following program so that it correctly handles the unfortunate situation when you have a stash of cookies but are out of milk.
#include using namespace std;int main(){try{cout < "number="" of="" cookies:="">int cookies;cin >> cookies;cout < "glasses="" of="" milk:="">int milk;cin >> milk;if (milk <= 0)="" throw="">=>double cpg = cookies / static_cast(milk);cout < cookies="">< "="">< milk="">< "="" glasses="" of="">< "you="" have="" "=""><>< "="" cookies="" for="" each="" glass="" of="">}catch(...){cerr < e="">< "="" cookies,="" and="" no="">< "go="" buy="" some="">}}
int main(){try{cout < "number="" of="" cookies:="">int cookies;cin >> cookies;cout < "glasses="" of="" milk:="">int milk;cin >> milk;if (milk <= 0)="" throw="">=>
double cpg = cookies / static_cast(milk);cout < cookies="">< "="">< milk="">< "="" glasses="" of="">< "you="" have="" "=""><>< "="" cookies="" for="" each="" glass="" of="">}catch(...){cerr < e="">< "="" cookies,="" and="" no="">< "go="" buy="" some="">}}
catch(...)
{cerr < e="">< "="" cookies,="" and="" no="">< "go="" buy="" some="">}}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here