Question

In: Computer Science

I need assistance on this problem in Pseudocode and in C++ Program Program 3: Give a...

I need assistance on this problem in Pseudocode and in C++ Program

Program 3: Give a baby $5,000! Did you know that, over the last century, the stock market has returned an average of 10%? You may not care, but you’d better pay attention to this one. If you were to give a newborn baby $5000, put that money in the stock market and NOT add any additional money per year, that money would grow to over $2.9 million by the time that baby is ready for retirement (67 years)! Don’t believe us? Check out the compound interest calculator from MoneyChimp and plug in the numbers!

To keep things simple, we’ll calculate interest in a simple way. You take the original amount (called the principle) and add back in a percentage rate of growth (called the interest rate) at the end of the year. For example, if we had $1,000 as our principle and had a 10% rate of growth, the next year we would have $1,100. The year after that, we would have $1,210 (or $1,100 plus 10% of $1,100). However, we usually add in additional money each year which, for simplicity, is included before calculating the interest.

Your task is to design (pseudocode) and implement (source) for a program that 1) reads in the principle, additional annual money, years to grow, and interest rate from the user, and 2) print out how much money they have each year. Task 3: think about when you earn the most money!

Lesson learned: whether it’s your code or your money, save early and save often…

Sample run 1:

Enter the principle: 2000

Enter the annual addition: 300

Enter the number of years to grow: 10

Enter the interest rate as a percentage: 10

Year 0: $2000

Year 1: $2530

Year 2: $3113

Year 3: $3754.3

Year 4: $4459.73

Year 5: $5235.7

Year 6: $6089.27

Year 7: $7028.2

Year 8: $8061.02

Year 9: $9197.12

Year 10: $10446.8

Sample run 2 (yeah, that’s $9.4MM):

Enter the principle: 5000

Enter the annual addition: 1000

Enter the number of years to grow: 67

Enter the interest rate as a percentage: 10

Year 0: $5000

Year 1: $6600

Year 2: $8360

Year 3: $10296

Year 4: $12425.6

Year 5: $14768.2 . .

Year 59: $4.41782e+06

Year 60: $4.86071e+06

Year 61: $5.34788e+06

Year 62: $5.88376e+06

Year 63: $6.47324e+06

Year 64: $7.12167e+06

Year 65: $7.83493e+06

Year 66: $8.61952e+06

Year 67: $9.48258e+06

This assignment is about Repetition Structures.

For Pseudocode, here are key words to use

: · DO … WHILE – A loop that will always run at least once ·

FOR … ENDFOR – A loop that runs until certain criteria is met ·

WHILE … ENDWHILE – A loop that runs only while certain criteria is met ·

FOREACH … ENDFOREACH – A loop that runs over elements in a data structure · BREAK - "break out" of the current loop (or other structure) you're in and start immediately after the loop · CONTINUE - skip over the current iteration of the loop and move on to the next one

Solutions

Expert Solution

Please find the PSEUDOCODE and C++ program below

/******************************************************************************
PSEUDOCODE:
===========
Read principle amount from user into principle
Read annual additional amount from user into annualAddition
Read number of years to grow value from user into numberOfYears
Read interest rate as percentage from user into interestRate
set year to 0
FOR each iteration of year till numberOfYears with increment of 1
IF year is 0
set updatedAmount to principle
ELSE
Add annualAddition to updatedAmount and assign it to updatedAmount
Calculate interestAdded by multiplying updatedAmount with (interestRate/100)
Add interestAdded to updatedAmount and assign it to updatedAmount
END IF
Print year and updatedAmount info
END FOR

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
//Defin variable to be used
double principle,annualAddition,updatedAmount,interestAdded;
float interestRate;
int numberOfYears, year;
  
//Read principle amount from user
cout<<endl<<"Enter the principle:";
cin>>principle;
  
//Read annual additional amount from user
cout<<endl<<"Enter the annual addition:";
cin>>annualAddition;
  
//Read number of years to grow value from user
cout<<endl<<"Enter the number of years to grow:";
cin>>numberOfYears;
  
//read interest rate from user
cout<<endl<<"Enter the interest rate as percentage:";
cin>>interestRate;
  
//traverse through for loop from year 0 to numberOfYears
for( year = 0 ; year <= numberOfYears; year++)
{
if(year == 0) //if 0th year, set updatedAmount to principle
{
updatedAmount = principle;
}
else
{
//For the othr years calculate updatedAmount
//by adding annualAddition
//and then applying interest rate calculation on sum of above two
updatedAmount = updatedAmount + annualAddition;
interestAdded = updatedAmount * interestRate/100;
updatedAmount = updatedAmount+ interestAdded;
}
  
//print year and the updatedAmount
cout<<endl<<"Year "<<year<<":"<<"$"<<updatedAmount;
}

return 0;
}

==============================================

OUTPUT

==============================================

Run1


Enter the principle:2000

Enter the annual addition:300

Enter the number of years to grow:10

Enter the interest rate as percentage:10

Year 0:$2000
Year 1:$2530
Year 2:$3113
Year 3:$3754.3
Year 4:$4459.73
Year 5:$5235.7
Year 6:$6089.27
Year 7:$7028.2
Year 8:$8061.02
Year 9:$9197.12
Year 10:$10446.8

Run2:


Enter the principle:5000

Enter the annual addition:1000

Enter the number of years to grow:67

Enter the interest rate as percentage:10

Year 0:$5000
Year 1:$6600
Year 2:$8360
Year 3:$10296
Year 4:$12425.6
Year 5:$14768.2
Year 6:$17345
Year 7:$20179.5
Year 8:$23297.4
Year 9:$26727.2
Year 10:$30499.9
Year 11:$34649.9
Year 12:$39214.9
Year 13:$44236.3
Year 14:$49760
Year 15:$55836
Year 16:$62519.6
Year 17:$69871.5
Year 18:$77958.7
Year 19:$86854.5
Year 20:$96640
Year 21:$107404
Year 22:$119244
Year 23:$132269
Year 24:$146596
Year 25:$162355
Year 26:$179691
Year 27:$198760
Year 28:$219736
Year 29:$242809
Year 30:$268190
Year 31:$296109
Year 32:$326820
Year 33:$360602
Year 34:$397763
Year 35:$438639
Year 36:$483603
Year 37:$533063
Year 38:$587469
Year 39:$647316
Year 40:$713148
Year 41:$785563
Year 42:$865219
Year 43:$952841
Year 44:$1.04923e+06
Year 45:$1.15525e+06
Year 46:$1.27187e+06
Year 47:$1.40016e+06
Year 48:$1.54128e+06
Year 49:$1.6965e+06
Year 50:$1.86725e+06
Year 51:$2.05508e+06
Year 52:$2.26169e+06
Year 53:$2.48896e+06
Year 54:$2.73895e+06
Year 55:$3.01395e+06
Year 56:$3.31644e+06
Year 57:$3.64918e+06
Year 58:$4.0152e+06
Year 59:$4.41782e+06
Year 60:$4.86071e+06
Year 61:$5.34788e+06
Year 62:$5.88376e+06
Year 63:$6.47324e+06
Year 64:$7.12167e+06
Year 65:$7.83493e+06
Year 66:$8.61952e+06
Year 67:$9.48258e+06


Related Solutions

I need assistance on this problem in Pseudocode and in C++ Program 1: Stay on the...
I need assistance on this problem in Pseudocode and in C++ Program 1: Stay on the Screen! Animation in video games is just like animation in movies – it’s drawn image by image (called “frames”). Before the game can draw a frame, it needs to update the position of the objects based on their velocities (among other things). To do that is relatively simple: add the velocity to the position of the object each frame. For this program, imagine we...
Hello, I need some assistance on completing this program in Pseudocode and in C++ Program 2:...
Hello, I need some assistance on completing this program in Pseudocode and in C++ Program 2: Buh-RING IT! For this assignment, you’re going to simulate a text-based Role-Playing Game (RPG). Design (pseudocode) and implement (source) for a program that reads in 1) the hero’s Hit Points (HP – or health), 2) the maximum damage the hero does per attack, 3) the monster’s HP and 4) the maximum monster’s damage per attack. When the player attacks, it will pick a random...
i need the pseudocode and python program for the following problem. Besides the user entering the...
i need the pseudocode and python program for the following problem. Besides the user entering the number of books purchased this order, they are asked for the number of points earned for the year before this order and the number of books ordered this year before this order. There are bonus points awarded based on the number of books previously ordered and number ordered now. These points should be added to the variable points: Current order: 0 Previous Orders >...
I need assistance translating a custom C++ program to MIPS. My C++ code is the following:...
I need assistance translating a custom C++ program to MIPS. My C++ code is the following: I have made numerous attempts on my own to no avail, any assistance is appreciated. Also, template code for this solution is provided below: #include int moveRobots(int *, int *, int, int ); int getNew(int, int); int main() { int x[4], y[4], i, j, myX = 25, myY = 25, move, status = 1; // initialize positions of four robots x[0] = 0; y[0]...
C Program and pseudocode for this problem. Write a C program that plays the game of...
C Program and pseudocode for this problem. Write a C program that plays the game of "Guess the number" as the following: Your program choose the number to be guessed by selecting an integer at random in the rang of 1 to 1000. The program then asks the use to guess the number. If the player's guess is incorrect, your program should loop until the player finally gets the number right. Your program keeps telling the player "Too High" or...
i need a pseudocode for a program in java that will convert dollars into euros and...
i need a pseudocode for a program in java that will convert dollars into euros and japanese yen using the print and prinln methods an if, if -else, statement a switch statement a while statement utilizes the file class uses the random class and random number generator and uses at least three methods other than main
This problem needs to be solved with source code. I need a C++ program that will...
This problem needs to be solved with source code. I need a C++ program that will help me solve this question. I need it in C++, please. Writing with comments so it maybe cleared. 1.2. We received the following ciphertext which was encoded with a shift cipher: xultpaajcxitltlxaarpjhtiwtgxktghidhipxciwtvgtpilpit ghlxiwiwtxgqadds. 1. Perform an attack against the cipher based on a letter frequency count: How many letters do you have to identify through a frequency count to recover the key? What is...
Need this in C# and also the Pseudocode. Program 4: In 1789, Benjamin Franklin is known...
Need this in C# and also the Pseudocode. Program 4: In 1789, Benjamin Franklin is known to have written “Our new Constitution is now established, and has an appearance that promises permanency; but in this world nothing can be said to be certain, except death and taxes.” Our federal tax system is a “graduated” tax system which is broken into seven segments. Essentially, the more you make, the higher your tax rate. For 2018, you can find the tax brackets...
I need a pseudocode and UML for this program. import java.util.Random; public class SortandSwapCount {   ...
I need a pseudocode and UML for this program. import java.util.Random; public class SortandSwapCount {    public static void main(String[] args) {        //Generate random array for test and copy that into 3 arrays        int[] arr1=new int[20];        int[] arr2=new int[20];        int[] arr3=new int[20];        int[] arr4=new int[20];        Random rand = new Random();        for (int i = 0; i < arr1.length; i++) {            //Generate random array...
C program and pseudocode for this problem. A parking garage charges a $2.00 minimum fee to...
C program and pseudocode for this problem. A parking garage charges a $2.00 minimum fee to park for up to three hours and additional $0.50 per hour over three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write a program that will calculate and print the parking charges for each of three customers who parked their cars in this garage yesterday. You should enter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT