I wanted to put the results of my exercises up, but I found that the appendix had the answer. Let's just forget it. I just did it myself. As mentioned before, if a friend has an idea and needs to make a small tool, I can help implement it, but it seems that everyone is very busy. SO, after completing chapter 2, I decided to make a tool:Simple deposit interest calculatorTo better review the previous knowledge.
Why is it simple?Full Storage(), And is not enabledAutomatic Transfer() Function, which allows you to easily compare the computing results with existing online tools and determine whether your program is correctly calculated ().
Of course, this is the v1.0 version. as I continue to study in the future, I will (not) Try (warranty) to improve this program, try to integrate all the learned knowledge points into each version of the program, so that there will be good changes in every version update of the program.
Console. writeLine ("operation instruction Description: Enter the principal (1), enter the deposit year (2), calculate (3), view the interest rate (4), and exit (0 )"); double benJ = 0, liV = 0, shouY = 0; int cunY = 0, cmdOrder = 0; do {cmdOrder = Convert. toInt16 (Console. readLine (); switch (cmdOrder) {case 1: {Console. writeLine ("Enter your principal amount:"); do {benJ = Convert. toDouble (Console. readLine (); if (benJ <100) Console. writeLine ("the minimum investment is 100, please enter again:") ;}while (benJ <100); shouY = benJ ;} break; case 2: {Cons Ole. writeLine ("Enter the retention period (1, 2, 3, 5):"); do {cunY = Convert. toInt16 (Console. readLine (); if (cunY <1) Console. writeLine ("The minimum storage period is 1 year. Please enter again:") ;}while (cunY <1) ;}switch (cunY) {default: case 1: liV = 3.00; break; case 2: liV = 3.75; break; case 3: liV = 4.25; break; case 5: liV = 4.75; break;} liV = liV/100.00; break; case 3: {for (int I = 1; I <= cunY; I ++) {shouY + = benJ * liV; // Console. wr IteLine ("{0}, {1}", shouY, liV);} Console. writeLine ("based on {0} year interest rate {1}, your principal {2} will grow to: {3}", cunY, liV, benJ, shouY); Console. writeLine ("NOTE: Automatic Storage is not enabled. ");} Break; case 4: {Console. writeLine ("Interest Rate Table, @ sfrost"); Console. writeLine ("1 year: 3.00%, 2 years: 3.75%"); Console. writeLine ("3 years: 4.25%, 5 years: 4.75%"); Console. writeLine ("\ n");} break; default: if (cmdOrder! = 0) Console. WriteLine ("enter a valid command number (1-9):"); break;} if (cmdOrder! = 0) Console. WriteLine ("Enter the Operation Command (1-9):") ;}while (cmdOrder! = 0); Console. WriteLine ("\ n"); Console. WriteLine ("Thanks for using ^ _ ^, press any key to exit ...... "); Console. ReadKey ();
After writing the program, I went back to the switch section in the book and found that I had understood a wrong concept. The book said, "It is illegal to execute the second case after executing a case ", I understood the case as a switch myself. Haha, no wonder this program can be debugged.
), With the further study, I believe this tool can be well developed. For example, each function item is encapsulated as a number of functions (for example). When using this function, you only need to input relevant parameters to return (to) the result.
Thank you for your advice ~~~~