Time deposit interest calculator-c ++
Post-processing becomes a practical function, which is recorded as a demo.
# Include
Using namespace std; int main () {int type; double money, period, rate, interest; cout <"welcome to the interest calculator! "<Endl; cout <" Enter the deposit amount: "; cin> money; cout <"====== deposit term ====" <endl; cout <"1. 3 months "<endl; cout <" 2. 6 months "<endl; cout <" 3. one year "<endl; cout <" 4. two years "<endl; cout <" 5. three years "<endl; cout <" 6. five Years "<endl; cout <" Enter the deposit term Code: "; cin> type; if (type> = 1 & type <= 6) {switch (type) // The switch condition processing is embedded in if {case 1: period = 0.25; rate = 0.031; break; case 2: period = 0.5; rate = 0.033; break; Case 3: period = 1; rate = 0.035; break; case 4: period = 2; rate = 0.044; break; case 5: period = 3; rate = 0.05; break; case 6: period = 5; rate = 0.055; break;} interest = money * period * rate; cout <"Expiration interest:" <interest <"Yuan, the sum of principal and interest is "<interest + money <" RMB. "<Endl;} elsecout <" An error occurred while selecting the deposit type! "<Endl; cout <" Thank you for your use. Thank you for coming next time! "<Endl; system (" pause "); return 0 ;}