logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
03009867267499815390
#1 Posted : Sunday, February 28, 2010 6:55:28 AM(UTC)
Quote
03009867267499815390
Rank: Advanced Member

Reputation:

Joined: 2/16/2010(UTC)
Posts: 30

I need to create a program where the user puts in a an amount of 'will' that their uncle left for them after he passed away. I need to also ask the user how much of the money they are going to use each year, and ask them how much interest their account has. The program should then print out the amount of money after each year considering the added interest and subtracting 'the amount used each year' (which is given by the user) I have completed most of the program...

I just need some help printing everything I need out and making sure my loop is correct.

This is copy of a sample run of what it should look like and below the sample run there is a copy of MY program and how far I have gotten:

Sample Run:

Year Payment Money Left
---- ------- ----------
1 1500.00 9500.00
2 1500.00 8950.00
3 1500.00 8345.00
4 1500.00 7679.50
5 1500.00 6947.45
6 1500.00 6142.20
7 1500.00 5256.41
8 1500.00 4282.06
9 1500.00 3210.26
10 1500.00 2031.29
11 1500.00 734.42
12 807.86 0.00



This is a copy of my program:

#include <stdio.h>

int main () {


int will, annual_amt_used, rate, counter, balance;

printf("What was the amount of the inheritance?\n");
scanf("%d", &will);
printf("What is the the amount you will use each year?\n");
scanf("%d", &annual_amt_used);
printf("What is the interest rate on the account?\n");
scanf("%d", &rate);

for (counter=0; counter < NOT SURE WHAT TO PUT HERE ; counter++)

{
balance=(balance * (rate/100))+balance; // balance= (balance * int_rate) +balance;
printf("%.2lf\n", balance);
}




system("PAUSE");
return 0;

}
Sponsor

Soan
#2 Posted : Sunday, February 28, 2010 7:08:52 AM(UTC)
Quote
Soan
Rank: Administration

Reputation:

Joined: 1/9/2010(UTC)
Posts: 449
Man
Location: India

Was thanked: 1 time(s) in 1 post(s)
You can use while loop instead of for loop like this:

while(balance > 0)
{
balance=(balance * (rate/100))+balance; // balance= (balance * int_rate) +balance;
printf("%.2lf\n", balance);
}
Quick Reply Show Quick Reply
Users browsing this topic
Guest
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.