1. ## Calculation Troubles

I have to take a 4-digit number and calculate it like this:

First 70 cubic meters \$5.00 minimum cost
Next 100 cubic meters 5.0 cents per cubic meter
Next 230 cubic meters 2.5 cents per cubic meter
Above 400 cubic meters 1.5 cents per cubic meter

Soo, for the number 203, it would calculate \$10.83. Ok, I've set it up numerous ways, and can't get anywhere near the correct price. Basically what I need to know is -- How can I break up one number into those 4 different calculations?

2. Ever heard of ifs? Sounds like they'd come in handy here.

3. Loops would be another option. But you need to show us what you got before we can go into any more detail

4. I'll attach what I've already got. Keep in mind I'm very new to this, hehehe. Thanks for the help so far.

5. I tried doing this for the calculations, but my numbers are still off by a few dollars.

cost1 = gasused%10 * 5.00;
cost2 = (gasused/10)%10 * 0.05;
cost3 = (gasused/10/10)%10 * 0.025;
cost4 = (gasused/10/10/10)%10 * 0.015;
totalcharges = cost1 + cost2 + cost3 + cost4;

6. This was fun:

PHP Code:
``` #include <iostream.h> #include <windows.h> #include <stdio.h> /* RULES: First 70 cubic meters \$5.00 minimum cost Next 100 cubic meters 5.0 cents per cubic meter Next 230 cubic meters 2.5 cents per cubic meter Above 400 cubic meters 1.5 cents per cubic meter */ int main()  {     int number;     float total = 5.0f;     float price;     printf("Enter cubic meters:\n");     cin >> number;     if( number <= 70 ) {         printf("Total price: \$%f.\n", total);         return 0;     } else if( number <= 170 )          price = 0.05f;     else if( number < 400 )         price = 0.025f;     else if( number > 400 )         price = 0.015f;              total += price * number;     printf("The total price is: \$%f.", total  );     return 0; }  ```

7. I'm glad you thought it was fun. Thanks for the help!