If money is left in a particular bank for more than 5 years, the interest rate given by the bank is 7.5%, else the interest rate is 5.4%. Write a program that prompt the user for the number of years that the money was left in the bank and display the appropriate interest rate depending on the value input. How many runs should you make to very that it works correctly?
I have run the code in c++ language.
#include <iostream>
using namespace std;
int main()
{
int years;
//prompts user to enter no of years
cout<<"Enter number of years that the money was left in the bank: ";
cin>>years;
//checks if years is greater than 5 then interest rate is 7.5%
if(years >5 ){
cout<<"Interest rate given by the bank is 7.5%";
}
//if years is less than 5 then it goes in else loop and interest rate is 7.5%
else{
cout<<"Interest rate given by the bank is 5.4%";
}
return 0;
}
I have run the program two times to very that it works correctly. one for entering number of years less than 5 and another for wntering number of years greater than 5.
1 . Output of
entering number of years greater than 5 is as
below.
2 . Output of entering number of years less than 5 is as below.
Get Answers For Free
Most questions answered within 1 hours.