Suppose your $1,000 is earning interest at 4% per year.
How many years you need to double your money?
Write a program to calculate the number of years!
Jump to PostWhew, it took me a while, but I think I've got it. Your turn.
(at least post what you have so far so someone can help you with your code)
Jump to Post1. First figure out how to do it by hand
2. Then search google to see how others have solved the problem
3. Finally write your program
Jump to Post1. ^ is the bitwise operator
2. I learned how to compound interest in 5th grade.
3. quadnobial is a non-existent equation
4. It was sarcastic
5. The OP obviously fell asleep in class or didn't listen, and as a result he should get a bad grade, though there's a …
Whew, it took me a while, but I think I've got it. Your turn.
(at least post what you have so far so someone can help you with your code)
1. First figure out how to do it by hand
2. Then search google to see how others have solved the problem
3. Finally write your program
Hmm... Obscure question. :P Is the interest computed at the end of each year or each month or each week or each day? :D Does the answer have to be in a whole year or decimal or year & month & day? ;)
#include <iostream>
using namespace std;
int main(){
double money=1000;
int years=0;
while(money<2000) {
money=money+4*money/100;
years++;
}
cout<<"after "<<years<<endl;
return 0;
It's already been solved, but for the above equation:
money *= (400/32)^9
would be much more suitable. C++ only excepts quadnobial equations with bitwise operation *=.
money *= (400/32)^9
??? I don't see any equation like that above? Also, the value of 'money' would go sky rocket in one go ???
??? I don't see any equation like that above? Also, the value of 'money' would go sky rocket in one go ???
Just ignore that post completely. It's ridiculous on so many levels. Then again, the OP deserves no better. With any luck, the OP will submit that line of code to the professor and will have to justify it in front of the class.
1. ^ is the bitwise operator
2. I learned how to compound interest in 5th grade.
3. quadnobial is a non-existent equation
4. It was sarcastic
5. The OP obviously fell asleep in class or didn't listen, and as a result he should get a bad grade, though there's a 75% chance he'll copy that code and have no idea how it works.
Suppose your $1,000 is earning interest at 4% per year.
How many years you need to double your money?Write a program to calculate the number of years!
You didn't indicate how you are going to pay for the answer ;)
Anyway I hope your professor is reading here so that you get big fat zero :)
>> 4. It was sarcastic
Glad to hear it. I was hoping so.
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.