Write a program that generates all the factors of a number entered by the user.
ID: 1798851 • Letter: W
Question
Write a program that generates all the factors of a number entered by the user. For instance, the number 12 has the factors 2 * 2 * 3. This program has the following requirements:I was able, with the help of a few folks from here, to write the above program in the following C++ code:
#include <iostream>
using namespace std;
int main()
{
int popA, popB;
double rateA, rateB;
int years=0;
cout<<"Enter population of Dogville: ";
cin>>popA;
cout<<"Enter growth rate of Dogville: ";
cin>>rateA;
cout<<"Enter population of Cattown: ";
cin>>popB;
cout<<"Enter growth rate of Cattown: ";
cin>>rateB;
while(popA<popB)
{
popA=(int)(popA*rateA+popA);
popB=(int)(popB*rateB+popB);
years++;
cout<<"Year Dogville Cattown ";
cout<<years<<" "<<popA<<" "<<popB<<endl;
}
rateA/=100.;
rateB/=100.;
system("pause");
return 0;
}
It works great for the first year figures. What would I need to add to make it calculate the growth for year 2, year 3, and year 4?? Please help.....
Explanation / Answer
#include using namespace std; int main() { int num; cin>>num; coutRelated 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.