Question

In: Computer Science

The First National Bank of Parkville recently opened up a new “So You Want to Be...

The First National Bank of Parkville recently opened up a new “So You Want to Be a Millionaire” savings account. The new account works as follows:

  • The bank doubles the customer’s balance every year until the customer’s balance reaches one million.
  • The customer isn’t allowed to touch the money (no deposits or withdrawals) until the customer’s balance reaches one million. If the customer dies before becoming a millionaire, the bank keeps the customer’s balance.
  • Note:Customers close to $1,000,000 tend to get “accidentally” run over in the bank’s parking lot.

Write a java program that prompts the user for a starting balance and then prints the number of years it takes to reach $100,000 and also the number of years it takes to reach $1,000,000.

Sample session:

Enter starting balance: 10000
It takes 4 years to reach $100,000.
It takes 7 years to reach $1,000,000.

Solutions

Expert Solution

/*Java program that prompts user to enter the starting balance and then find a number of years to reach 100000$ and  number of years to reach 1000000$ */
//Millionaire.java
import java.util.Scanner;
public class Millionaire
{
   public static void main(String[] args)
   {
       //create an instance of Scanner class
       Scanner kboard=new Scanner(System.in);
       //declare variables
       double balance=0;
       double amount=0;
       int year=0;
       boolean run=true;
       //set one lack
       final double ONE_LACK=1_000_00;
       //set one million
       final double ONE_MILLION=1_000_000;
      
       System.out.print("Enter starting balance: ");
       //read balance from keyboard
       balance=Double.parseDouble(kboard.nextLine());
       //set balance
       amount=balance;
       //Loop to reach one lack
       while(amount<=ONE_LACK && run )
       {
           //double the amount
           amount=2*amount;
           //increment the year by 1
           year++;
          
           if(amount>=ONE_LACK)
               //set run to false if amount reached 100000
               run=false;
       }
       //print the years to reach one lack dollars
       System.out.println("It takes "+year+" years to reach $"+ONE_LACK);
      
       //Reset year to 0
       year=0;
       //Reset run to true
       run=true;
       //set balance to amount
       amount=balance;
       //Loop to reach one million
       while(amount<=ONE_MILLION && run )
       {
      
           //double the amount
           amount=2*amount;
           //increment the year by 1
           year++;
           //set run to false if amount reached 1000000
           if(amount>=ONE_MILLION)
               run=false;
       }
       //print the years to reach one million dollars
       System.out.println("It takes "+year+" years to reach $"+ONE_MILLION);  
   }
}
--------------------------------------Sample Run#---------------------------------------------------------------


Related Solutions

In 2009, New York First National Bank acquired New Jersey National Bank. In an exchange, New...
In 2009, New York First National Bank acquired New Jersey National Bank. In an exchange, New York First National Bank issued three series of preferred stock for New Jersey National Bank's net assets. Series Senior A (the most senior series), was given to four of New Jersey National Bank's creditors so that the debt could then be retired. The four preferred shareholders are listed as follows: two regional banks, one money center bank, and a non-financial corporation. Senior Series A...
The Clearwater National Bank is planning to set up a new branch.This new branch is...
The Clearwater National Bank is planning to set up a new branch. This new branch is anticipated to generate 5 percent of the total business of the bank after it is opened. The bank also expects the return for this branch to be 15 percent with a standard deviation of 5 percent. Currently the bank has a 10 percent rate of return with a standard deviation of 5 percent. The correlation between the bank's current return and returns on the...
Recently, the Smithsonian Museum in Washington DC has opened a new national museum of African American...
Recently, the Smithsonian Museum in Washington DC has opened a new national museum of African American History and culture. Go to the Smithsonian website At the top left of the page click on menu Click on Visit Choose the restaurant there- The sweet home cafe Go to the menu of the restaurant at the museum and see what is said about the foods that are offered there. Take a look at all the regional foods on the menu. What do...
You are the employed by the First National Bank. This bank has $5 million in capital....
You are the employed by the First National Bank. This bank has $5 million in capital. They have $100 in checkable deposits. Of that they keep only the 10% required reserves and loan the rest out. In $45 million in business loans and $50 million in residential mortgages. How well capitalized is First National Bank? Calculate the risk weighted level of assets and risk weighted leverage ratio. Why are leverage (capital) ratios important for financial regulators and institutions?
You are the employed by the First National Bank. This bank has $5 million in capital....
You are the employed by the First National Bank. This bank has $5 million in capital. They have $100 in checkable deposits. Of that they keep only the 10% required reserves and loan the rest out. In $45 million in business loans and $50 million in residential mortgages. How well capitalized is First National Bank? Calculate the risk weighted level of assets and risk weighted leverage ratio. Why are leverage (capital) ratios important for financial regulators and institutions?
You opened an account and deposited X Dollars on January 1, 2002 in National City Bank....
You opened an account and deposited X Dollars on January 1, 2002 in National City Bank. Any balance in the account will earn 5% per year. You withdrew $500 on January 1, 2006 and $500 on January 1, 2008. You closed out this account on January 1, 2011 and received $700. How much did you initially deposit (X) in National City at the time you opened the account?
You are a new company that have just opened up. You need to implement a privileged...
You are a new company that have just opened up. You need to implement a privileged user training module for privileged users. What should the awareness training include and how will it be enforced?
First National Bank Balance sheet                               Assets        &
First National Bank Balance sheet                               Assets            Liabilities Rate-sensitive    $20 million         $50 million Fixed-rate           $80 million         $50 million 4) Given the above table and assuming that the average duration of its assets is four years, while the average duration of its liabilities is three years, then a 5 percentage point increase in interest rates will cause the net worth of First National to ________ (increase/decline) by ________ (5% /10%/ 15%/ 20%) of the total original asset value (use...
You have an opportunity to acquire a property from First Capital Bank. The bank recently obtained...
You have an opportunity to acquire a property from First Capital Bank. The bank recently obtained the property from a borrower who defaulted on his loan. First Capital is offering the property for $200,000. If you buy the property you will have to (1) spend $10,500 on various acquisition related expenses and (2) exactly $2,000/month during the next 12 months for repairs in order to prepare for sale. Because First Capital Bank would like to sell the property as soon...
a) On the first day of the month Javier opened a bank account in the name...
a) On the first day of the month Javier opened a bank account in the name of the business; in which I deposit $ 25,000. b) $ 600 was paid in cash for the month's rent. c) A used truck was purchased for $ 8,000 in cash. d) Tools were purchased for $ 3,000 on credit at Home Depot. e) $ 150 was paid in cash for the use of electric power. f) $ 1,500 was paid in advance for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT