I wrote the following code for a homework problem, but it's stuck in an infinate loop. I'm not sure how to correct that problem. The other issue is I want the answer to be given in two decimal places and not rounded in any way and it appears that my answers are being rounded. Any help would be greatful!
// this program will calculate the salary after a set number of days
// the user will input the number of days to obtain the salary
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
// declare variables
float n = 0;
float total = 0;
float dollaramount = 0;
// prompt user for the number of days
cout << "Please enter the number of days to obtain the sum of $0.01 per\n"
"day that doubles for the amount of days that you input:";
cin >> n;
while (n >= 1 || n <= 30)
{
total = pow(2, n) - 1;
dollaramount = total/100;
cout << "The total dollar amount will be:" << setprecision (2)
<< fixed << dollaramount << " on the " << n << " day.";
}
cout << " You entered a number outside of 1 through 30, please\n"
"start over.";
system ("pause");
return 0;
}