Answer to Question #27905 in C++ for shreya yadav

Question #27905
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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS