Question

In: Computer Science

Please do in java Program 3: Give a baby $5,000! Did you know that, over the...

Please do in java

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

Solutions

Expert Solution

import java.util.Scanner;

public class Sample {

      public static void main(String[] args) {

            // TODO Auto-generated method stub

           

            double principle=0,addition=0,years=0, rate =0;

            double amt=0;

            Scanner scan = new Scanner(System.in);

            //Getting the inputs from user

            System.out.print("Enter the principle: ");

            principle = scan.nextDouble();

            System.out.print("Enter the annual addition: ");

            addition = scan.nextDouble();

            System.out.print("Enter the number of years to grow: ");

            years = scan.nextDouble();

            System.out.print("Enter the interest rate as a percentage: ");

            rate = scan.nextDouble();

            amt = principle;       

            //Calculating and printing out the results.

            for(int i=0;i<=years;i++){

                  System.out.println("Year "+ i+ ": $"+ amt);

                  amt=amt+addition;

                  amt=amt+(double)((rate/100)*amt);

            }

            scan.close();

      }

}

output:


Related Solutions

Did you know that there are over 500 types of bananas in the world? Did you...
Did you know that there are over 500 types of bananas in the world? Did you also know that bananas are an excellent source of potassium, fiber, and vitamin B-6 as well as serve as a powerful antioxidant? However, most people might not be aware of the prolific amount of banana consuming possibilities that are available to them. Wouldn't it be amazing if we have a program that would randomly recommend a type of banana for someone to eat every...
Please do this in java program. In this assignment you are required to implement the Producer...
Please do this in java program. In this assignment you are required to implement the Producer Consumer Problem . Assume that there is only one Producer and there is only one Consumer. 1. The problem you will be solving is the bounded-buffer producer-consumer problem. You are required to implement this assignment in Java This buffer can hold a fixed number of items. This buffer needs to be a first-in first-out (FIFO) buffer. You should implement this as a Circular Buffer...
PLEASE DO THIS IN C#.Is there a Prius version? Did you know that the average Boeing...
PLEASE DO THIS IN C#.Is there a Prius version? Did you know that the average Boeing 747 airplane uses approximately 1 gallon of fuel per second? Given the speed of the airplane, that means it gets 5 gallons to the mile. No, not 5 miles to the gallon, 5 gallons to the mile. You may be questioning why such a horribly inefficient machine is allowed to exist, but you’ll be happy to find out that, because this airplane hold 568...
PLEASE DO NOT OVERRIDE ANY EXCEPTIONS TASK: You want to develop a Java program that will...
PLEASE DO NOT OVERRIDE ANY EXCEPTIONS TASK: You want to develop a Java program that will allow you to keep track of a set of employees. In reviewing your employee list, you notice that your employees fall into two categories: Salaried and Hourly. The following table shows the information that you keep in your employee list for each type of employee. Field Type Salaried Hourly id int Yes Yes name String Yes Yes title String Yes No position String No...
HELLO CAN YOU PLEASE DO THIS JAVA PROGRAM I WILL LEAVE AWESOME RATING. THANK YOU IN...
HELLO CAN YOU PLEASE DO THIS JAVA PROGRAM I WILL LEAVE AWESOME RATING. THANK YOU IN ADVANCE. QUESTION Suppose you are designing a game called King of the Stacks. The rules of the game are as follows:  The game is played with two (2) players.  There are three (3) different Stacks in the game.  Each turn, a player pushes a disk on top of exactly one of the three Stacks. Players alternate turns throughout the game. Each...
HELLO CAN YOU PLEASE DO THIS JAVA PROGRAM WITH THE DIFFERNT CLASSES LISTED BELOW. I WILL...
HELLO CAN YOU PLEASE DO THIS JAVA PROGRAM WITH THE DIFFERNT CLASSES LISTED BELOW. I WILL LEAVE AWESOME RATING. THANK YOU IN ADVANCE. The code needed for this assignment has to somehow implement a stack interface (including a vector stack, array stack, and a linked stack). The classes needed are the Game class, the disk class, the driver, and the stack interface (including arraystack, linkedstack, and vectorstack) QUESTION Suppose you are designing a game called King of the Stacks. The...
Calculate Interest in a Java program. If you know the balance and the annual percentage interest...
Calculate Interest in a Java program. If you know the balance and the annual percentage interest rate, you can compute the interest on the next monthly payment using the following formula: interest = balance * (annualInterestRate/1200) Write a program that reads the balance and the annual percentage interest rate and displays the interest for the next month. Create a scanner Prompt the user to enter a name and create variable for scanner Prompt the user to enter a balance and...
How well do you really know your customers? And how well did they want to know...
How well do you really know your customers? And how well did they want to know you right?
IN C++ LANGUAGE PLEASE:::: Is there a Prius version? Did you know that the average Boeing...
IN C++ LANGUAGE PLEASE:::: Is there a Prius version? Did you know that the average Boeing 747 airplane uses approximately 1 gallon of fuel per second?  Given the speed of the airplane, that means it gets 5 gallons to the mile. No, not 5 miles to the gallon, 5 gallons to the mile.   You may be questioning why such a horribly inefficient machine is allowed to exist, but you’ll be happy to find out that, because this airplane hold 568 people, it...
3. Consider the string:”34456754”. Please find the frequency of each number. With a java program.
3. Consider the string:”34456754”. Please find the frequency of each number. With a java program.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT