Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program which allows the user to enter a integer. The program should cal

ID: 3688754 • Letter: W

Question

Write a program which allows the user to enter a integer. The program should call a recursive method that determines if the number is one of the binary multiples (2, 4, 8, 16, 32, 64, etc.). Accomplish this without the use of any boolean variables. The final date/time to submit this assignment is Friday, April 15th at midnight. A financial services company guarantees a 1 % monthly compounded return on your investment. You want to see how long it takes to reach a total of $1,000,000 (million dollars) in investment plus return. Write a program that allows the user to enter a continuous monthly investment (Example - $500 every month) or ($1,000 every month). The program should call a recursive method that returns and displays the total months needed to reach the $1,000,000 goal. Example - At the 1 % compounded monthly rate, and a $1,000 monthly investment, the first month should yield $1,010.00, the second month $2,030.10, the third month $3,060.40, the fourth month $4,101.01, etc. Display how many total months it takes the user to reach the million dollar goal. Remember, the user should be able to input the monthly continuing investment. The rate is always 1 % and compounded monthly. The final date/time to submit this assignment is Friday, April 15th at midnight.

Explanation / Answer

Binary Multiple Recursion

#include <iostream>
using namespace std;

int isMultiple2(int x){
   if (x==1){
       return 1;
   } else if(x%2==0){
       return isMultiple2(x/2);
   } else {
       return 0;
   }
}
int main (){
   int x;
   cout<<"Enter the integer:";
   cin>>x;
   if (x==1){
       cout<<"No the number is one of the binary multiples! ";
   } else {
       if(isMultiple2(x)==1){
           cout<<"Yes the number is one of the binary multiples! ";
       } else {
           cout<<"No the number is one of the binary multiples! ";
       }
   }
}

Finance Recursion:

#include <iostream>
#include <cmath>
using namespace std;

int getCompound(float monthlyP,float P,float r,float A){
   // cout<<P<<r<<A<<endl;
   // int t = 0;// t = time in months
   if (P>=A){
       return 0;
   } else {
       // cout<<P*pow((1+r/12),12)<<endl;
       if(P!=monthlyP){
           P += monthlyP;  
       }
       P = P*pow((1+r/12),12);
       cout<<P<<endl;
       if(P>=A){
           return getCompound(monthlyP,P,r,A);
       } else {
           return 1+getCompound(monthlyP,P,r,A);
       }
   }
}
int main (){
   // formulae A = P (1+r/n)^nt
   float P,r,A;
   cout<<"Enter the monthly Investment amount(P):";
   cin>>P;
   cout<<"Enter the monthly interest rate (r):";
   cin>>r;
   cout<<"Enter the goal amount to be achieved (A):";
   cin>>A;  
   float rate = (r/100.0);
   // cout<<rate;
   cout<<"Time taken to reach the goal is: " << getCompound(P,P,rate,A)<<endl;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote