I need some help with the body of this program, more specificallythe actual body
ID: 3617176 • Letter: I
Question
I need some help with the body of this program, more specificallythe actual body statement. The problem reads:Writea program to calculate the sum of $.01 a day, doubled forn number of days. For example, on the first day youwould receive $.01; on the second day you would receive $.02, for atotal of $.03. On the third day you would receive $.04, for atotal of $.07. Get the input for the number of days, but makesure its between 1 and 30 days. Display the number of centsaccumulated, along with the number of days entered by the user.
Thank you for any help that could be provided.
Explanation / Answer
#include<iostream> #include<math> using namespace std; int main() { double sum=0.0;
int num;
while(true) { cout<<"Enter Number of Days: "; cin>>num; if(num>1&&num<30) break; else cout<<"Number of days must be in between (1-30)"; }
for (short i=1;i<n=num;i++) sum = sum + (0.01*(pow(2.0, num-1.0));
cout << "Total cents: " << sum <<endl;
cout << "Total days: " << n << endl;
system("pause"); return 0; }