using namespace std;

#include <iostream>

#include <iomanip>

#include <math.h>

Go()

{

double netBalance=0;

int d1=0;

int d2=0;

double payment=0;

double rate=0;

while (netBalance<=0)

{

cout << "Please input the net balance :>";

cin >> netBalance;

}

while (d1<=0)

{

cout << "please input # of days in billing cycle :>";

cin >> d1;

}

while (d2<=0)

{

cout << "please input # of payment days :>";

cin >> d2;

}

while (payment<=0)

{

cout << "please input the payment :>";

cin >> payment;

}

while (rate<=0)

{

cout << "input the rate PERCENT :>";

cin >> rate;

}

double averageDailyBalance = (netBalance * d1 - payment*d2)/d1;

double interest = averageDailyBalance * rate/100;

cout << fixed << setprecision(2) << "average daily balance is " << averageDailyBalance << endl;

cout << fixed << setprecision(2) << " interest is " << interest << endl;

}

int main()

{

Go();

}