Starting from:
$30

$24

Homework 3 Solution

Files to submit: investments.c

Time it took Matthew to Complete: 30 mins




All programs must compile without warnings when using the -Wall and -Werror options



Submit only the files requested



Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc



Your program must match the output exactly to receive credit.



Make sure that all prompts and output match mine exactly.



Easiest way to do this is to copy and paste them



All input will be valid unless stated otherwise



Print all real numbers to two decimal places unless otherwise stated



The examples provided in the prompts do not represent all possible input you can receive.



All inputs in the examples in the prompt are underlined



You don't have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program
If you have questions please post them on Piazza



Restrictions




No global variables are allowed



Your main function may only declare variables, call other functions, and assign variables values.
You must use loops to solve this problem.



Assumptions




Input is NOT guaranteed to be valid



If invalid input is entered your program should continue to ask the user for input until valid input is entered
For this program you will be determining if it is better to put as much money as you can towards your student loans before saving for retirement or if it is better to only pay the minimum payment on your loan and invest the rest.



Points to pay attention to:




Interest rates given are annual interest rates but we will assume that interest is
compounded monthly so the real rates to use will be
1
of what are given
12




We will assume that interest is compounded on our accounts before any payments or contributions are made to them.
If the user has not finished paying off all of their loans by the time they retire a warning message should be printed






Cautions about using this program for your own investment strategy




This program is assuming you would be investing your money in a Roth IRA



Turns out there is a simpler answer than this program to finding out how you should invest. Remind me to tell you about it you finish it.



Examples:




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.

More products