|
C-Menu 0.2.9
A User Interface Toolkit
|
Installment Loan Calculator. More...
#include <math.h>#include <signal.h>#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>Go to the source code of this file.
Macros | |
| #define | FALSE 0 |
| #define | TRUE 1 |
Functions | |
| void | ABEND (int) |
| double | accept_i () |
| double | accept_n () |
| double | accept_pmt () |
| double | accept_pv () |
| void | accept_str (char *s) |
| double | calculate_i (double, double, double) |
| double | calculate_n (double, double, double) |
| double | calculate_pmt (double, double, double) |
| double | calculate_pv (double, double, double) |
| void | error_press_any_key (char *) |
| char * | format_currency (float) |
| char * | format_interest (float) |
| int | is_numeric (char *) |
| int | main (int argc, char **argv) |
| iloan is a trivial application to demonstrate how a command-line program can be integrated into C-Menu Form with simple file, argument, or pipe i-o. | |
| void | numbers (char *d, char *s) |
Variables | |
| int | f_i = 0 |
| int | f_n = 0 |
| int | f_pmt = 0 |
| int | f_pv = 0 |
| bool | f_quiet = false |
| char | in_str [BUFSIZ+1] |
| void ABEND | ( | int | e | ) |
| double accept_i | ( | ) |
Definition at line 221 of file iloan.c.
References accept_str(), error_press_any_key(), in_str, and is_numeric().
Referenced by main().
| double accept_n | ( | ) |
Definition at line 205 of file iloan.c.
References accept_str(), error_press_any_key(), in_str, and is_numeric().
Referenced by main().
| double accept_pmt | ( | ) |
Definition at line 242 of file iloan.c.
References accept_str(), error_press_any_key(), in_str, and is_numeric().
Referenced by main().
| double accept_pv | ( | ) |
Definition at line 184 of file iloan.c.
References accept_str(), error_press_any_key(), in_str, and is_numeric().
Referenced by main().
| void accept_str | ( | char * | s | ) |
Definition at line 349 of file iloan.c.
References in_str.
Referenced by accept_i(), accept_n(), accept_pmt(), and accept_pv().
| double calculate_i | ( | double | pv, |
| double | n, | ||
| double | pmt ) |
Definition at line 291 of file iloan.c.
References error_press_any_key(), f_quiet, and format_interest().
Referenced by main().
| double calculate_n | ( | double | pv, |
| double | i, | ||
| double | pmt ) |
Definition at line 279 of file iloan.c.
References error_press_any_key(), f_quiet, and format_currency().
Referenced by main().
| double calculate_pmt | ( | double | pv, |
| double | n, | ||
| double | i ) |
Definition at line 328 of file iloan.c.
References error_press_any_key(), f_quiet, and format_currency().
Referenced by main().
| double calculate_pv | ( | double | n, |
| double | i, | ||
| double | pmt ) |
Definition at line 266 of file iloan.c.
References error_press_any_key(), f_quiet, and format_currency().
Referenced by main().
| void error_press_any_key | ( | char * | s | ) |
Definition at line 260 of file iloan.c.
Referenced by accept_i(), accept_n(), accept_pmt(), accept_pv(), calculate_i(), calculate_n(), calculate_pmt(), calculate_pv(), and main().
| char * format_currency | ( | float | a | ) |
Definition at line 354 of file iloan.c.
Referenced by calculate_n(), calculate_pmt(), calculate_pv(), and main().
| char * format_interest | ( | float | a | ) |
Definition at line 393 of file iloan.c.
Referenced by calculate_i(), and main().
| int is_numeric | ( | char * | s | ) |
Definition at line 340 of file iloan.c.
Referenced by accept_i(), accept_n(), accept_pmt(), and accept_pv().
| int main | ( | int | argc, |
| char ** | argv ) |
iloan is a trivial application to demonstrate how a command-line program can be integrated into C-Menu Form with simple file, argument, or pipe i-o.
Positional arguments: present_value The present value of the loan (the amount borrowed). number_of_payments The total number of payments to be made. interest_rate The annual interest rate (as a percentage). payment_amount The amount of each payment. The program calculates the missing value based on the three provided values. For example, if the present value, number of payments, and interest rate are provided, it will calculate the payment amount. If the present value, interest rate, and payment amount are provided, it will calculate the number of payments, and so on. The program can be used in a non-interactive way by passing the four values as arguments, with the value to be calculated set to 0. For example, to calculate the payment amount for a $10,000 loan with a 5% annual interest rate and 60 monthly payments, you could run:
This is proof-of-concept code, and is not intended for production use. It is not designed to be robust, and does not handle all edge cases or input errors. It is intended solely to demonstrate how a simple command-line program can be integrated into C-Menu Form. In the future, more sophisticated abstractions, such as async event handlers, serialization, rpc, database, and a standardized plugin interface will be integrated into C-Menu. Feel free to modify and enhance this code as needed, but please do not use it in production without proper testing and validation. It is provided as-is without any warranty or support. Use at your own risk.
Definition at line 74 of file iloan.c.
References ABEND(), accept_i(), accept_n(), accept_pmt(), accept_pv(), calculate_i(), calculate_n(), calculate_pmt(), calculate_pv(), error_press_any_key(), f_i, f_n, f_pmt, f_pv, f_quiet, format_currency(), format_interest(), and numbers().
| void numbers | ( | char * | d, |
| char * | s ) |
| bool f_quiet = false |
Definition at line 41 of file iloan.c.
Referenced by calculate_i(), calculate_n(), calculate_pmt(), calculate_pv(), and main().
| char in_str[BUFSIZ+1] |
Definition at line 20 of file iloan.c.
Referenced by accept_i(), accept_n(), accept_pmt(), accept_pv(), and accept_str().