Informatics - Copying CPP Files Cash Flow Calculator (week 9)
Hello everyone! Meet me again on my second blogpost after midterm break. As I stated in previous blogpost, here I will show you two C++ files as the continuation of the Cash Flow Calculator program. A C++ file (commonly referred to as a .cpp file) is a source code file used to write programs in the C++ programming language. This code will be longer than the previous one. So, without further do, here's the codes!.
The first file of the C++ file is CashFlowCalculator.cpp. This code is the longest one of the C++ code. Here's the code:
This code defines a CashFlowCalculator class that calculates the present value of future cash flows. Present value is the current worth of a future amount of money or stream of cash flows, discounted at a given rate of interest. It allows you to:
- Set a discount rate (e.g., interest rate).
- Add cash payments with their corresponding time periods.
- Calculate the total present value, which is the current worth of all future cash payments.
The second C++ file is the main.cpp. Here's the main code:
This code calculates the present value of future cash payments based on a user-provided interest rate. The purpose of this code is to evaluate the current value of future cash flows interactively.
Steps:
- Input Interest Rate: The program takes the interest rate as a command-line argument.
- Add Payments: The user enters payment periods and amounts interactively. Input -1 to stop.
- Calculate Present Value: It computes the total present value of all payments using the interest rate.
That's all the three codes that we need to run the Cash Flow Calculator program. I will show you the steps of how to run this code on windows. So, stay tuned for my next blogpost. See you all!
.png)
.png)
.png)
Komentar
Posting Komentar