Hello, How do you sum up in c++? this is my program that calculates pay. You sta
ID: 3616703 • Letter: H
Question
Hello,How do you sum up in c++?
this is my program that calculates pay. You start outwith .01 penny and every day it doubles....how to do I total it allup?
while (payDay <= days) { cout << fixed << setprecision(2); raise = pow(2.0, payDay); pay = .01 * raise / 2; cout << payDay++ << " $"<< pay << endl; }
How do you sum up in c++?
this is my program that calculates pay. You start outwith .01 penny and every day it doubles....how to do I total it allup?
while (payDay <= days) { cout << fixed << setprecision(2); raise = pow(2.0, payDay); pay = .01 * raise / 2; cout << payDay++ << " $"<< pay << endl; } while (payDay <= days) { cout << fixed << setprecision(2); raise = pow(2.0, payDay); pay = .01 * raise / 2; cout << payDay++ << " $"<< pay << endl; }
Explanation / Answer
#include <iostream>#include <math.h>
using namespace std;
int main()
{
int payDay=1, days=25;
double pay=0.0,raise=0.0;
while (days >=1)
{
raise =pow(2.0, payDay);
pay+=0.01*raise/2;
cout<< payDay++ << " $ " << pay <<endl;
days--;
}
System("pause");
return 0;
}
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int payDay=1, days=25;
double pay=0.0,raise=0.0;
while (days >=1)
{
raise =pow(2.0, payDay);
pay+=0.01*raise/2;
cout<< payDay++ << " $ " << pay <<endl;
days--;
}
System("pause");
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.