Google Answers Logo
View Question
 
Q: A simple C programming question ( No Answer,   0 Comments )
Question  
Subject: A simple C programming question
Category: Computers > Programming
Asked by: osito_49-ga
List Price: $5.00
Posted: 17 Mar 2004 00:22 PST
Expires: 18 Mar 2004 16:15 PST
Question ID: 317495
I need code that does the following:

calculates the balance of a savings account at the end of a period of
time. It should ask the user for the annual interest rate, the
starting balance, and the number of months that have passed since the
account was established. The loop should then iterate once for every
month, performing the following:

A) Ask the user for the amount deposited into the account during the
month. The asking should be repeated until there is no more deposit
(Do not accept negative numbers as well as letters.) These amounts
should be added to the balance.

B) Ask the user for the amount withdrawn from the account during the
month. The asking should be repeated until there is no more withdrawn
(Do not accept negative numbers as well as letters.) These amounts
should be subtracted from the balance.

 C) Calculate the monthly interest. The monthly interest rate is the
annual interest rate divided by twelve. Multiply the monthly interest
rate by the current balance of the month, and add the result to the
balance.

At the end of each month, the program should display the ending
balance, the total amount of deposits, the total amount of
withdrawals, and the total interest earned in the related month.
Before ending the program, there should be a summary displayed the
ending balance, the total amount of deposits, the total amount of
withdrawals, and the total interest earned in the period. Insert
comments in the program to document the program internally.  Attach a
design flow chart to a hard copy of the source code of the program.

Note: if a negative balance is calculated at any point, a message
should be displayed indicating the account has been closed and the
loop should be terminated, and of course there should be a summary at
the end as described above.

below is a pseudocode that describes what should be done:

_______________________________________________________________________________


Prompt the user for the AnnualInterestRate
Read in AnnualInterestRate as a percentage
Prompt the user for the starting balance
Read in the StartingBalance
Prompt the user for the number of months the account has been open
Read in the number of Months

Calculate the MonthlyInterestRate
	(it needs to be a decimal number - not a percentage)
	(MonthlyInterestRate = AnnualRate / 1200)
Initialize the EndingBalance to StartingBalance
Initialize the TotalDeposits; TotalWithdrawals, and TotalInterest to 0

For each month the account has been open:
	prompt user for the amount deposited during the current month
	Read in the Deposit
	While (Deposit < 0)
		display an error message
		read in another Deposit
	End of the While
	Add the deposit to the total Deposits
	Add the deposit to the EndingBalance

	Prompt user for the amount Withdrawal during the current month
	Read in the Withdrawal
	While (Withdrawal < 0)
		display an error message
		read in another Withdrawal
	End of the While
	Add the Withdrawal to the TotalWithdrawal
	Subtract the withdrawal from the EndingBalance
	if the ending balance is less than zero:
		display a message indication the account has been closed
		terminate the loop
	else Calculate
		Interest = EndingBalance * MonthlyInterestRate
	Add the Interest to the EndingBalance
	Add the Interest to the TotalInterest
	End If
End of the For

Display each of these items on a separate line:
		Starting Balance:			$
		Total Deposits:				$
		Total Withdrawals:			$
		Total Interest Credited:		$
		Ending Balance:				$

		Display the End of Program Message
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy