Postingan

Informatics - Making Minimarket Discount Program in C++ Version 2 (week 13)

Gambar
Are you ready for version two? Don't worry it's only needed a little addition and I'm sure you can do it by yourself! Your boss will be proud of you and maybe you'll get bonus? So, without any further do, let's start!  So, the first version is only for counting the discount and the total price. But what if your minimarket wants to give a bonus item for a specific threshold? So, in second version I will show you how to add the bonus item for specific threshold.  We start from the first code that we have made: //program minimarket_discount_v1.cpp #include <iostream> #include <iomanip> using namespace std; int main (){ double totalPurchase, discount = 0.0, finalPrice; cout << "Please enter the amount of purchase (in Rupiah): Rp"; cin >> totalPurchase; if (totalPurchase >= 1000000){     discount = 0.2; } else if (totalPurchase >= 500000){     discount = 0.1; } else if (totalPurchase >= 200000){     discount = 0.05; } e...

Informatics - Making Minimarket Discount Program in C++ version 1 (Week 12)

Gambar
 Happy new year all! 💥 I know it's pretty late but anyways I'm writing my first blog on this year. In this blog I'm going to share my assignment of making a minimarket discount program in C++. There will be two version of this program and here, I'm going to show you the first version. The purpose of this program is to check the total purchase amount against the specified thresholds to determine the applicable discount rate. It will also calculate the final price by subtracting the discount for the total purchase. As a reference to make this program, I was given a similar program.  // program GradeConverter.cpp #include <iostream> #include <iomanip> using namespace std; int main (){ int score; string grade; cout << "Please input numerical score (1-100):"; cin >> score; if(score <= 100){ grade = "A+"; } else if (score >= 80 ){ grade = "A"; } else if (score >= 70 ){ grade = "B"; } else if (scor...

Informatics - Making a Main C++ Program to Run all the Calculator Program (week 11)

Gambar
Hi everyone! So, in this blog I want to share to you about how I make a main C++ program to run all the financial calculator program. Financial calculator program is program that used to calculate financial problem based on users need. The goal of this program is user can calculate their financial problem by choosing one of the programs available.  There will be interest rate, compound interest rate, cash flow, and moving average calculator inside of this financial calculator. Notes: - Interest rate is the percentage charged by a lender to a borrower for the use of money, or the percentage earned by an investor on their money over time. It is expressed as an annual percentage of the principal amount. - Compound interest rate is the rate at which interest is calculated not only on the initial principal amount but also on any accumulated interest from previous periods. This results in the interest "compounding" over time, which can grow the total amount much faster than simple ...

Informatics - Run the Cash Flow Calculator Program (week 10)

Gambar
Hi all! Here I am again making another post for you. As I promised last week on my previous post, I will show you how to run the Cash Flow Calculator program on windows. Are you excited? Let's run the program together! I will show you how to run it step by step.  First step: The first step is open the folder you made for this program on your file explorer. Here, I put my folder on the documents.  Here, I named my file as Cashflow Calculator.  Second step: Right click then choose the "open in terminal" option.  After you click the "open in terminal" option you will straight go to the Command Prompt.  Third step: Type "g++ -c ./*.cpp" to compile the programs. If it succeeds you will go straight to the next step, then type "ls" to list the files in the folder. But if your program can't be compiled there will be "error" word on the command prompt, and it means that there's something wrong with your program.  As you can see there...

Informatics - Copying CPP Files Cash Flow Calculator (week 9)

Gambar
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 seco...

Informatics - Copy Header Files Code CashFlowCalculator (week 8)

Gambar
Hello everyone! How have you been? Waiting for my blogpost? haha just kidding. I'm back with my informatics program again. This time I am copying a code from my teacher. This code is about Cash Flow Calculator. Cash flow is the net balance of cash moving in and out of a business over a period of time. A cash flow calculator is a financial tool designed to help individuals, businesses, or investors estimate, analyze, and manage their cash flow over a specific period. It calculates the net amount of cash inflows and outflows, providing insight into financial health, profitability, or liquidity. Here, I'll show you the code that I copied.  The first code is the header file of the program which is CashFlowCalculator.h. Header files contain a set of predefined standard library functions. The .h is the extension of the header files in c++ and we request to use a header file in our program by including it with the c++ preprocessing directive “#include”. Line 1:  Allows the progr...

Informatics - Decimal Formatting Program (week 7)

Gambar
Hi everyone, here we go again with informatics c++ program. This block is actually still related with the previous block. So, I recommend you read my previous  blog  first.  As you can see there, the result of the calculation is quite confusing right? There's no such proper dots or coma to separate the numbers. Here, with this code program in c++, we can format the decimal and also make the numbers readable and tidier. I use code blocks to compile and run the program. Attach is the syntax of the program: Line 1: provides access to the std::locale class and related functionality, which allows us to handle locale-specific settings such as number formatting. Line 2: allows the use of standard input/output streams, including std::cout for output. Line 3: provides functions for manipulating input and output streams, such as setting precision and formatting. Line 5: defines a new class comma_numpunct, which inherits from std::numpunct<char>. std::numpunct is a c...