I need the program to act as a vending machine, keep running total and determine change if applicable.
#include <iostream>
using namespace std;
int main()
{
    cout << "A deep-fried twinkie costs $3.50" << endl;
    double change, n = 0, d = 0, q = 0, D = 0, rTotal = 0;
    do
    {
        cout << "Insert (n)ickel, (d)ime, (q)uarter, or (D)ollar: ";
        cin >> rTotal;
        if (rTotal == n)
            rTotal += 0.05;
        if (rTotal == d)
            rTotal += 0.10;
        if (rTotal == q)
            rTotal += 0.25;
        if (rTotal == D)
            rTotal += 1.00;
         cout << "You've inserted $" << rTotal << endl;
        cout.setf(ios::fixed);
        cout.precision(2);
        } while (rTotal <= 3.5);
        if (rTotal > 3.5)
            change = rTotal - 3.5;
            return 0;
}
 
     
    