/********************************************************************************************
3_29r1.cpp
    Jim Millard
    for CO311
Revised to put the "work" in a separate function
Simple program that calculates the APR on a T-bill based on standard purchase criteria
********************************************************************************************/
#include <iostream>
#include <string>
using namespace std;
float getROI(const float endValue, const float beginValue, const int days);
int main()
    {
    int maturityDays;
    float denomination, purchasePrice, APR;
    //inform and prompt the user
    cout << endl << "This program will compute the APR (annual percentage rate) on" << endl;
    cout << "a Treasury bill." << endl;
    cout << "Please enter the matured value of the T-bill: $";
    cin >> denomination;
    cout << "Please enter the price you paid for the T-bill: $";
    cin >> purchasePrice;
    cout << "Please enter the maturation period in days: ";
    cin >> maturityDays;
    APR = getROI(denomination, purchasePrice, maturityDays);
    //output the results
    cout.precision(2);
    cout.setf(ios::fixed);
    cout << endl << "The APR of your T-bill is: " << APR << "%" << endl;
    return 0;
    }
float getROI(const float endValue, const float beginValue, const int days)
    {
    const int yearDays = 365;
    //interim storage objects
    float interestFactor, periods;
    periods = yearDays/Days;
    interestFactor = endValue/beginValue - 1.0;
    return (100.0 * interestFactor * periods);
    }