I have to write a program that calculates charges for a ISP provider, there are 3 packages all that charge different rates per the amount of hours used. I have created this program 2 times both in a single .cpp file then in a structured program. Now we are required to set it up as a module and our book does not touch on them at all.

I have basic input stuff in my code as of now but I have no idea how to insert the calculations to determine if its a leap year or to get the amount due. I know I could just throw the code into the application file but that defeats the purpose of a module? I do not know how to set up the calulation in the module and then link it to the app.

here are my 3 files:

header:
Code:
//ISP_Header.h   Module Public Functions declarations


namespace ISP
{
    bool setPkg(int);
    int  getPkg(); 

    bool setMth(int);
    int  getMth();

    bool setYr(int);
    int getYr();

    bool setHrs(int);
    int  getHrs(); 

    void calcChgs();
    double getChgs();



}
here is my Module:
Code:
//ISP_Module.cpp   Module Implementation


#include "ISP_Header.h"

namespace    //Prvate namepace
{
//Private Data Structure
    int pkg;
    int hrs;
    int mth;
    int yr;



//Private Helper Functions

bool isValidPkg( int p )
{
    return p>=1 && p<=3;
}

bool isValidMth(int h)
{
    return h>=0 && h<=12;
}
bool isValidYr(int y)
{	
    return y>=1;
}

bool isValidHrs(int h)
{
    return h>=0 && h<=720;
}



}//Private namespace


//Public Functions -- Availble to the application

bool ISP::setPkg( int p )
{
    return isValidPkg(p) ? (pkg = p, true) : false;
}   
    
int ISP::getPkg()
{
    return pkg;
}

bool ISP::setMth(int m)
{
    return isValidMth(m) ? (mth=m, true) : false;
}

int ISP::getMth()
{
    return mth;
}

bool ISP::setYr(int y)
{
    return isValidYr(y) ? (yr=y, true) : false;
}

int ISP::getYr()
{
    return yr;
}

bool ISP::setHrs(int h)
{
    return isValidHrs(h) ? (hrs=h, true) : false;
}

int ISP::getHrs()
{
    return hrs;
}
and my application:
Code:
//Application.cpp  Test the ISP Module public functions


#include <iostream>
using namespace std;

#include "ISP_Header.h"

void main()
{
    int p;
    int m;
    int y;
    int h;

{
    do
    {
        cout<<"Pkg: ";
        cin >> p;

    }
    while(  ! ISP::setPkg(p)  );

    do
    {
        cout<<"Mth: ";
        cin >> m;
    }
    while( ! ISP::setMth(m) );

    do
    {
        cout<<"Year: ";
        cin>> y;
    }
    while( ! ISP::setYr(y) );

    do
    {
        cout<<"Hrs: ";
        cin >> h;
    }
    while( ! ISP::setHrs(h) );



    cout<<"pkg = "<< ISP::getPkg()<<endl;
    cout<<"mth = "<< ISP::getMth()<<endl;
    cout<<"year = "<<ISP::getYr()<<endl;
    cout<<"hrs = "<< ISP::getHrs()<<endl;

}//end for



}//end main


Here is some code from a previous program to determine a leap year, how would I put this into a module and link it to the app?

Code:
		switch (y % 4)
		{
		case 0:
			if (y % 100 == 0)
			{
				if (y % 400 == 0)
				{
					cout << y << " is a leap year" << endl;
			//year = leapYr
				}
				else
					cout << "  " << y << " isn't a leap year." << endl;
			}
			else
				cout << y << " is a leap year!" << endl;
			break;

		default:
			cout << y << " isn't a leap year." << endl;
			break;
		}
I could just paste this in under the hours section in the application but how do I add this code in the module and then link it to the application??

I think if I can see how this is inserted I should be able to handle the package calculations.