Write a c++ program to compute the simple interest on a given amount and time.i the time is 2 years or more calculate it with 3%rate of interest and 5% otherwise.
1
Expert's answer
2013-04-09T09:00:32-0400
#include <iostream> using namespace std; const double LONG_RATE = 0.02; const double SHORT_RATE = 0.05; int main () { //initialamount of money doubleini_amount; intyears; cout<< "Please input initial amount of money: "; cin>> ini_amount; cout<< "Please input number of years: "; cin>> years; cout<< "Simple interest will be: " << (years>= 2 ?(1. + LONG_RATE*(double)years) * ini_amount :(1. + SHORT_RATE*(double)years) * ini_amount ) <<endl; return0; }
Comments
Leave a comment