Im taking a C++ class, which was offered online only and my professor is bad communication.
I need to:
Write a program which calculates the value of a fixed deposit at the time of maturity. Your program should be able to accept the following input from the user:
1. The deposit amount.
2. The period for deposit.
Use the following formula for interest.
Interest amount = (Amount Deposited * Annual %Interest Rate * Period of deposit in years)/100
Assume an annual interest rate of 10%.
I think I have everything if you guys can look over it. THE THING I NEED HELP ON IS HOW DO I GET THE 10 PERCENT TO ALWAYS BE IN THE RATE I THINK THATS WHAT THE PROFESSOR WANTS?
#include<iostream>
usingnamespace std;
int main ()
{
int p,r,t,i;
cout<<"Enter Deposit Amount : ";
cin>>p;
cout<<"Enter Rate : ";
cin>>r;
cout<<"Enter Period of Deposit in years : ";
cin>>t;
i=(p*r*t)/100;
cout<<"Simple intrest is :"<<i<<endl;
return 0;
}
Uhh wouldn't you just not ask the user for a rate ? Or, for whatever reason, you want to ask the user for a rate, but whatever they put it doesn't matter because you have it always at 10%. In this case, I would do this:
const double rate = 0.1;
The const makes sure that whatever happens, rate is always going to be the value 0.1. I also put double instead of int because I think int is just for whole numbers, while double can be used for like 4.5 0.3 etc, and 10% is 0.10.
I am a beginner too so if this is wrong please correct me.