76 836
Assignments Done
Successfully Done
In June 2019

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.
Expert's answer
#include <iostream> using namespace std;
const double LONG_RATE = 0.02;
const double SHORT_RATE = 0.05; int main () {
//initialamount of money
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 )

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions