This is C++ How to Program 7th Edition.
I have to Modify the Package shipping program to include exception handling.
Here is the code please help me modify this i started abit stuck need help exception handling.
// ExceptionHandling.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <stdexcept>
#include <exception>
using namespace std;
using std::runtime_error;
int _tmain(int argc, _TCHAR* argv[])
{
int totalPay = 0;
int hours = 0;
int avgPay;
cout << "Enter the total pay: ";
cin >> totalPay;
cout << "Enter the hours worked: ";
cin >> hours;
try
{
if (hours == 0)
throw exception();
avgPay = totalPay / hours;
cout << "Your average pay per hour is: $" << avgPay << endl;
}
catch (exception &p)
{
cout << "OOPS!!!!!" << endl;
}
return 0;
}