Question

In: Computer Science

This is a c++ questions that calculates the investments/ loans. Below is the sample output, which...

This is a c++ questions that calculates the investments/ loans. Below is the sample output, which have few scenerios.

Enter how much money you will be putting towards loans/retirement each month: 500
Enter how much you owe in loans: 40000
Enter the annual interest rate of the loans: 0.03 Enter your minimum monthly loan payment: 405.32 Enter your current age: 22

     Enter the age you plan to retire at: 65
     Enter the annual rate of return you predict for your
     investments: .05
     You should only make the minimum payments on your loan and apply
     the rest towards retirement.
     If you do you will have $592888.96 when you retire as opposed to
     $587281.54 if you payed off your loan before investing.

Enter how much money you will be putting towards loans/retirement each month: 1053
Enter how much you owe in loans: 50000
Enter the annual interest rate of the loans: 0.06 Enter your minimum monthly loan payment: 350 Enter your current age: 25

     Enter the age you plan to retire at: 70
     Enter the annual rate of return you predict for your
     investments: 0.05
     You should apply all $1053.00 towards your loan before making
     any investments.
   If you do you will have $1651149.44 when you retire as opposed
   to $1619732.68 if you only made minimum payments.Enter how much
   money you will be putting towards loans/retirement each month:
   50
   Enter how much you owe in loans: 1000
   Enter the annual interest rate of the loans: 0.05
   Enter your minimum monthly loan payment: 400
   You didn't set aside enough money to pay off our loans. Ending
   program.

Enter how much money you will be putting towards loans/retirement each month: 500
Enter how much you owe in loans: 10000
Enter the annual interest rate of the loans: .02 Enter your minimum monthly loan payment: 100 Enter your current age: 18

   Enter the age you plan to retire at: 20
   Enter the annual rate of return you predict for your
   investments: 0.07
   Warning! After you retire you will still have $7961.19 in loans
   left.
   You should only make the minimum payments on your loan and apply
   the rest towards retirement.
   If you do you will have $10272.41 when you retire as opposed to
   $1835.38 if you payed off your loan before investing.

Enter how much money you will be putting towards loans/retirement each month: bob
Enter how much money you will be putting towards loans/retirement each month: cat

   Enter how much money you will be putting towards
   loans/retirement each month: -3
   Enter how much money you will be putting towards
   loans/retirement each month: 250
   Enter how much you owe in loans: something
   Enter how much you owe in loans: 25 boys
   Enter how much you owe in loans: 1000
   Enter the annual interest rate of the loans: ziggy
   Enter the annual interest rate of the loans: -3
   Enter the annual interest rate of the loans: .1
   Enter your minimum monthly loan payment: 50 50
   Enter your minimum monthly loan payment: 25
   Enter your current age: -5
   Enter your current age: 20
   Enter the age you plan to retire at: 18
   Enter the age you plan to retire at: 65
   Enter the annual rate of return you predict for your
   investments: -8
   Enter the annual rate of return you predict for your
   investments: 0.04
   You should apply all $250.00 towards your loan before making any
investments.
If you do you will have $371259.10 when you retire as opposed to
$370579.15 if you only made minimum payments.

Solutions

Expert Solution

Copyable Code:

#include <iostream>

using namespace std;

void main()

{

      double money = 0.0;

      double Ol = 0.0;

      double aIR = 0.0;

      double mMP = 0.0;

      double Rr = 0.0;

      double money_save = 0.0;

      double cA = 0.0;

      int PAge = 0;

      int RAge = 0;

      //initialiese loop variable

      int i = 0;

cout<<"\nEnter how much money you will be putting towards loans/retirement each month";

      cin>>money;

      cout<<"\nEnter how much you owe in loans";

      cin>>Ol;

      cout<<"\nEnter the annual interest rate of the loans:";

      cin>>aIR;

      cout<<"\nEnter your minimum monthly loan payment:";

      cin>>mMP;

      cout<<"\nEnter your current age:";

      cin>>PAge;

      cout<<"\nEnter the age you plan to retire at:";

      cin>>RAge;

cout<<"\n Enter the annual rate of return you predict for your investments";

      cin>>Rr;

      cout<<"\n";

      for(i = 0; i < (RAge - PAge) * 12; ++i)

      {

      if(Ol > 0) {

            cout<<"\n Month:"<<i+1;

            cout<<"\n Current savings:"<<money_save;

            cA = money_save * (Rr/12);

            money_save += cA;

            money_save += (money - mMP);

            if(mMP > Ol) {

            money_save += -(Ol - mMP);

            Ol = 0;

            }

            else

            {

            Ol+= (Ol * aIR/12);

            Ol -= mMP;

            }

            cout<<"\nLoans owned:"<<Ol;

            cout<<"After interest savings:"<<money_save;

            cout<<"Compound amount:"<<cA;

      }

      else

      {

            cout<<"\n Month"<<i+1;

            cA = money_save * (Rr/12.0);

            money_save += money;

            money_save += cA;

            cout<<"\nCurrent savings:"<<money_save;

            cout<<"\nLoans owned:"<<Ol;

            cout<<"After interest savings:"<<money_save;

            cout<<"\n Compunded amount:"<<cA;

      }

      }

      cout<<"\nSavings:"<<money_save;

      if(mMP * (RAge - PAge) * 12 >= Ol) {

cout<<"\n Do minimum payments on loan and remaining towards retirement.";

      }

      else

      {

            cout<<"Apply all"<<money<<"towads loan";

      }

      system("pause");

}


Related Solutions

Write Lexical Analyzer program in C language. Below is the sample input and ouput. /* output...
Write Lexical Analyzer program in C language. Below is the sample input and ouput. /* output Enter the string: if(a<b){a=10;} Tokens are identifier :if punctuation mark : ( identifier :a operator:< identifier :b punctuation mark : ) punctuation mark : { identifier :a operator:= constant :10 punctuation mark : ; punctuation mark : } */
a) Write down the SQL Statement for the below Queries b) Supply sample tale output c)...
a) Write down the SQL Statement for the below Queries b) Supply sample tale output c) the database Used is the University Schema downloaded at lecture 1. Write a query to display the name for those Students who gets more Tot_Cred than the Student whose ID is 55739. 2. Write a query to display the name salary, department name, instructor id for those instructors who works in the same department as the instructor works whose id is 83821. 3. Write...
C program that demonstrate tree traversal. see for the sample output. Sample Output: How many node...
C program that demonstrate tree traversal. see for the sample output. Sample Output: How many node do you have in your tree : 5 Enter root: 20 if you want to add to the left press 0 otherwise press 1 answer: 0 Enter next node: 10 if you want to add to the left press 0 otherwise press 1 answer: 0 Enter next node: 8 if you want to add to the left press 0 otherwise press 1 answer: 0...
Create a C++ program which will accept an unlimited number of scores and calculates the average...
Create a C++ program which will accept an unlimited number of scores and calculates the average score. You will also need to prompt for the total points possible. Assume each test is worth 100 points. Requirements. • Enter the Student ID first, then prompt for grades. Keep prompt- ing for grades until the client enters ’calc’. That triggers final pro- cessing. • Make your code as reliable as possible. • Make your program output easy to read. • You cannot...
C Programming: POSIX: Producer / Consumer Modify the code below so that the Producer.c file calculates...
C Programming: POSIX: Producer / Consumer Modify the code below so that the Producer.c file calculates the Fibonacci sequence and writes the sequence to the shared-memory object. The Consumer.c file should then output the sequence. Producer.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <sys/shm.h> #include <sys/stat.h> #include <sys/mman.h> #include <zconf.h> int main() { /* The size (in bytes) of shared-memory object */ const int SIZE = 4096; /* The name of shared-memory object */ const char *Obj =...
C++ Give an example of overloading by implementing a function square(x), which calculates the square of...
C++ Give an example of overloading by implementing a function square(x), which calculates the square of x, (also known as x*x or x 2 ) where the input can be int or double.
provide a C code (only C please) that gives the output below: ************************************ *         Menu HW...
provide a C code (only C please) that gives the output below: ************************************ *         Menu HW #4 * * POLYNOMIAL OPERATIONS * * 1. Creating polynomials * * 2. Adding polynomials * * 3. Multiplying polynomials. * * 4. Displaying polynomials * * 5. Clearing polynomials. * * 6. Quit. * *********************************** Select the option (1 through 6): 7 You should not be in this class! ************************************* *         Menu HW #4 * * POLYNOMIAL OPERATIONS * * 1. Creating polynomials...
Write a C program with call to functions to produce the output given below. // the...
Write a C program with call to functions to produce the output given below. // the requirements are that there should be 5 files; intList.h, intList.c, hw3.h, hw3.c, and main.c. please only C and use Linked List. thank you. For the 5 different files, he wants it this way: 1) main.c This file just consists of the main() function, which only consists of the displayClassInfo() function call, and the runMenuHw3() function call. 2) intList.h This file would have the IntNode...
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT