| Next Step |
|
//Loan Demo Program, Prof Barimani - Tutorials & code designed & provided by Prof. Barimani 02-01/2010 //ProgII class //STEPS: Translate to Java // #include <iostream> #include <cmath> #include <iomanip> #include <string> using namespace std; int main() { cout<<"Enter Loan Amount? "; double loan; cin>>loan; if (loan <0) cout<<"Loan must be positive\n"; else { cout<<"Enter annual interest Rate%? "; double AIR; cin>>AIR; AIR/=100; if (AIR <0) cout<<"AIR cannot be negative\n"; else { cout<<"1. Month 2. Year? "; string ans; cin>>ans; int month; //should also check to see if Month is positive if (ans == "2") { cout<<"Enter period in Years? "; cin>>month; month*=12; } else { cout<<"Enter period in Month? "; cin>>month; } double MIR= AIR /12.0; double MP= (loan * MIR)/ (1.0- pow(1.0+MIR, -month)); cout<<"Monthly payment= "< } system("PAUSE"); return 0; } |