Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you must use loops and C language function to compute this C program. use camel case. when required use long float(%lf) instead of float(%f). use

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

you must use loops and C language function to compute this C program. use camel case. when required use long float(%lf) instead of float(%f). use relevant comments to explain what u did and why.

page 1 Loops and Functions vill give you experience writing software that makes use of a loop to numerically compute the total payment if you use a credit card and de make payments on time. You will include your own C-language function to de SO. For background information, check your lecture notes and online (do a search on "loops in c" and "functions in c"). Using Software to Compute Interest Charges Already, or soon, you will consider credit cards as a form of payment. You will likely take out loans at various points of your life, perhaps to buy a car or a house or to start and/or sustain a business. One of the important things to know is how much these might cost you. Here we will take a simplified look at this problem. If your programming is up to it, you might want to extend the code you develop past the restrictions we will use. But be sure to submit the code that answers this specific lab problem! Many credit cards (but not other loans) do not charge you if you pay the amount owing on the monthly statement in a small amount of time after the statement is issued, but otherwise they charge monthly interest. The interest then becomes part of the amount owing, and will be part of the amount charged interest in the next month. So if you pay these cards every month they are "free" but if you don't you will pay interest that accumulates (known as "compounding interest"). As an example, say you have a one dollar purchase on your credit card with one percent interest per month, Initially you owe $1.00 At the end of the month you owe $1.00 plus $0.01 At the end of the next month you owe $1.01 plus $0.0101 And they do track those fractions of cents, and they do charge you for them, usually rounding up to the nearest cent. page 2 The amount due at the end of the month (where money is owed at the start of the month) is thus d = u+p+((u+p) *) - where d is the amount due at the end of the month, u is the previous unpaid amount due, p are the purchases for that month, r is the amount repaid that month and i is the interest rate per month. The calculated d become the u for the next month. Note that typical credit card rates are upwards of 19 percent per year. Loans from "cash advance" shops can be 7 times greater or more! We will assume that each card gives a monthly statement and calculates any monthly interest charges. We will NOT consider penalties or special charges or minimum payments. We will assume that there could be an amount owing already on the card at the start of the period we are considering, then monthly purchases at a regular rate and monthly payments at a regular rate. In particular the program should conform to the following: Rules on end-of-the-month payments: - If you owe any money at the start of a month, you pay interest on the amount owed plus any amount purchased in that month. Any unpaid amount plus interest after any payments becomes the owed amount at the start of the next month. - If you don't owe any money at the start of a month, but you don't pay off all that you purchase at the end of the month, you pay interest on the entire amount of the purchase. The unpaid amount plus interest after any payments becomes the owed amount at the start of the next month. If you don't owe any money at the start of a month, and pay off all that you purchase at the end of the month, you pay no interest and you do not owe money at the start of the next month. The total amount owed cannot be less than zero. The actual payment cannot be greater than the total amount owed. If your monthly payment exceeds the total amount owed, the payment becomes the total amount owed. The interest will compound on a monthly basis. page 3 The Code to be written You are to write a C program, in a file called Lab4.c, which calculates the cost of using a credit card for a number of months. The user will enter the initial amount owed on the card. purchase amount per month, the payments per month, the yearly interest rate (the monthly rate will be 1/12 of this) and the number of months to be considered for the calculations. The number of months will be a non-negative integer, the others possibly decimal fractions. You need not check for valid inputs. You must use iteration to do this calculation, and you must use a function (although it is trivial) to calculate the amount owing at the end of the month. This should be of the form of this prototype: double owed Amount (double interest, double owedFromPreviousMonth, double purchases, double monthly Payment); The Sample Outputs should help you see the pattern of calculations. Sample Outputs Enter amount already owed on card: 0 Enter purchase amount per month: 100 Enter payment amount per month: 100 Enter yearly interest rate as percent: 24 Enter number of months to consider: 12 Total purchased value: 1200.00 Total interest charges: 0.00 Enter amount already owed on card: 100 Enter purchase amount per month: 0 Enter payment amount per month: 100 Enter yearly interest rate as percent: 24 Enter number of months to consider: 12 Total purchased value: 100.00 Total interest charges: 2.04 Enter amount already owed on card: 100 Enter purchase amount per month: 0 Enter payment amount per month: 200 Enter yearly interest rate as percent: 24 Enter number of months to consider: 12 Total purchased value: 100.00 Total interest charges: 2.00 page 4 Enter amount already owed on card: 0 Enter purchase amount per month: 100 Enter payment amount per month: 0 Enter yearly interest rate as percent: 24 Enter number of months to consider: 12 Total purchased value: 1200.00 Total interest charges: 168.03 Enter amount already owed on card: 1000 Enter purchase amount per month: 0 Enter payment amount per month: 0 Enter yearly interest rate as percent: 24 Enter number of months to consider: 12 Total purchased value: 1000.00 Total interest charges: 268.24 Enter amount already owed on card: 1000 Enter purchase amount per month: 200 Enter payment amount per month: 150 Enter yearly interest rate as percent: 19.5 Enter number of months to consider: 12 Total purchased value: 3400.00 Total interest charges: 312.73 Things to note from examples: Borrow for a month, no big deal. If you let it go for a year at higher rates, you're giving away significant amounts to the financial institution - imagine living on 20 percent less money! Max out your credit card and not pay it back quickly and the costs get enormous. Tip: when you start writing your program, first just create it such that it takes input once, computes the results, and then quits (without re-asking for input). Once you are confident that this computation works, wrap the whole thing in another loop so that you can continuously re-ask for input according the spec. This will make writing the code and debugging it easier

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

Factors Affecting Conflict

Answered: 1 week ago

Question

Describe the factors that lead to productive conflict

Answered: 1 week ago

Question

Understanding Conflict Conflict Triggers

Answered: 1 week ago