// Compound Interest Calculator // By: Chris Benard // Free to distribute, delete, change, anything // Including Libs #include #include // Defining all needed number variables as floating float inter, compinter, x, princ, yrs, orig, temp, realint; // Defining enters as a string char *enters=""; void main(int argc, char *argv[]) { // Checks to see if one of the arguments is a form of help...if so // give help and exit. if (argc==2) { if (strcmp(argv[1],"help") || strcmp(argv[1],"h") || strcmp(argv[1],"-h") || strcmp(argv[1],"/h") || strcmp(argv[1],"--help") || strcmp(argv[1],"/help")) { printf("\n"); printf("By typing %s, you will be prompted for numbers.\n",argv[0]); printf("If you wish, on the commandline, you may specify three\n"); printf(" arguments, the principle, the number of years, and\n"); printf(" the percent interest which will be less than one.\n"); printf("i.e.-- %s 5000 5 .08 will calculate $5000 for 5 years\n", argv[0]); printf(" at 8%% interest."); printf("\n\nBy: Chris Benard\n"); exit(0); } } // checks for command line args and assigns them their respective values // in the program if found...also decides if four lines of skipping // is needed if (argc==4) { princ = atof(argv[1]); yrs = atof(argv[2]); inter = atof(argv[3]); } else { // if not cmdline args, interactively prompt printf("What is the principle? "); scanf("%f",&princ); printf("\nWhat is the number of years? "); scanf("%f",&yrs); printf("\nWhat is the interest rate[<1.0]? "); scanf("%f",&inter); // assign 4 line skip after prompting to separate output from input enters="\n\n\n\n"; } // keep the value for the original input to show later orig = princ; for(x=0; x