Write a program to show how money increases over time given a particular interes
ID: 3586537 • Letter: W
Question
Write a program to show how money increases over time given a particular interest rate and a regular deposit amount. The program is written with parameters so that these values could be changed to compute a different interest rate, number of years, starting amount or deposit amount. Your program also asks the user for name, phone and addresses and display the user's info in the format provided in the sample output. A shell for your program has be provided. You are not allowed to change the list of the parameters or the return type for any of the provided methods. Your program must exactly provide the following output word by word. Sample output Welcome to interest calculator This program shows how money increases over time given a particular interest rate and a regular deposit amount How many times do you want to use this app: 2 Enter your first and last name separating with one space (all letters in lowercase): gita faroughi Enter your phone number in the format(123 456 7890):123 456 7890 Enter your address in the following format(6000 J street Sacramento:CA 95819): 6000j street:Scaramento:CA 95819 Name: FAROUGHI GITA Phone: 123-456-7890 Address: 6000 J street Sacramento CA 95819 Enter the initial amount: 1000 Enter the number of the years: 25 Enter the interest rate: 6.7 Enter the monthly deposit: 100 Year Interest start Deposit New Balance 1000.0Explanation / Answer
I am providing you solution in C++.
All things will remain same except the standard input and output which you will take through JAVA inbuilt functions.
Find your code below:
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
// your code goes here
string name;
long long int ph;
string add;
cout <<"Enter First Name and Last Name with space: ";
getline(cin,name);
cout<<"Enter your phone number ";
//cin>>ph;
scanf("%lld",&ph);
cout<<"Enter your Address ";
getline(cin,add);
cout<<name<<endl;
cout<<ph<<endl;
int l=strlen(add.c_str());
for(int i=0;i<l;i++)
{
if(add[i]==':')
add[i]=' ';
printf("%c",add[i]);
}
cout<<endl;
float initam;
int yrs;
float inrate;
float monthlyD;
int i;
cin>>initam;
cin>>yrs;
cin>>inrate;
cin>>monthlyD;
float P=initam;
int count=1;
for(i=0;i<yrs;i++)
{
float temp=(P*(inrate/100));
P+=(monthlyD+temp);
cout<<count<<" "<<temp<<" "<<monthlyD<<" "<<P<<endl;
count++;
// printf("%f",temp);
}
return 0;
}
Input:
Alex decosta
1234567890 52Steet:cornfiels:CA
1000
25
6.7
100
Output obtain from online compiler after running code:
Thanks,If have any query or problem in understanding main logic behind the code feel free to write comment
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.