(1) Not sure if you were told to work with floats but they are a pain to use for money because of the internal rounding. You are better off using an integer and working in pennies and just dividing and multiplying by 100 when you have to - usually when you need to print the values.
(2) I just did your mid-range as an example and it seems to work and, if not, it should be close enough for you to correct.
(3) The two you are stuck on (1 & 3) have multiple phones so presumably you are parsing that in the beginning. I just simulated it here. This won't get you home free but hopefully reduces the confusion - some of which seemed to be of your own making.
#include <iostream>
#include <cmath>
using namespace std;
const float SERVICE_FEE = 1.44;
const float MID_FEE = 49.99;
const int BASE_MID_MIN = 500;
const float MID_MIN = 0.08;
const int BASE_MID_TEXT = 500;
const float MID_TEXT = 0.08;
const int BASE_MID_DATA = 500;
const float MID_DATA = 2.88;
float midPlanCharge (int min, int texts, float data)
{
float total = MID_FEE;
data *= 1000;
if (min > BASE_MID_MIN)
total += (min - BASE_MID_MIN) * MID_MIN;
if (texts > BASE_MID_TEXT)
total += (texts - BASE_MID_TEXT) * MID_TEXT;
if (data > BASE_MID_DATA)
total += roundf((data - BASE_MID_DATA) / BASE_MID_DATA) * MID_DATA;
return total;
}
int main(int argc, char *argv[])
{
float accTotal = 0.0;
accTotal += midPlanCharge(333, 550, 0.9);
accTotal += midPlanCharge(501, 444, 0.4);
accTotal += (accTotal * 0.081); //tax
accTotal += SERVICE_FEE * 2; //service fee on 2 phones
cout << "Total = " << accTotal << endl;
return(0);
}
Output : Total = 118.482