Question
in C#
Assignment #2: Millionaire Write a program that takes as input the amount of money deposited as well as the current rate of i
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here I am providing the answer for the above question:

Code:

using System;

class Years
{
static void Main()
{
int percentage;
double princialAmount,rate;
Console.WriteLine("Enter principal amount:");
princialAmount = double.Parse(Console.ReadLine());
Console.WriteLine("Enter interest rate as percentage:");
percentage = Convert.ToInt32(Console.ReadLine());
//finding rate by dividing percentage by 100.
rate=percentage/100.0;
  
int years=0;
double yearlyInterest,newBalance=princialAmount,previousBalence=princialAmount;
while(newBalance<=1000000) //calculating number of years, stoping the loop if it is >100000(1 million)
{
yearlyInterest=newBalance*rate;
newBalance=previousBalence+yearlyInterest;
years++;
previousBalence=newBalance;
}
Console.WriteLine("No of years for becoming millionaire:");
Console.WriteLine(years);
}
}

Screenshot:

using System; class Years static void Main() int percentage; double princialAmount,rate; Console.WriteLine(Enter principal a

Output:

Enter principal amount: 50000 Enter interest rate as percentage: 50 No of years for becoming millionaire:

Hoping that the above answer will help you...Thank you...

Add a comment
Know the answer?
Add Answer to:
in C# Assignment #2: Millionaire Write a program that takes as input the amount of money...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Write a function called division that takes as input 2 numbers and divides them without...

    Python Write a function called division that takes as input 2 numbers and divides them without first checking what the inputs contain, returning the value of the division if it succeeds. If one of the inputs is not a number, print 'Cannot divide anything but numbers'. If denominator is 0, print 'Attempted to divide by zero'. If anything else causes the division to not work, print 'An unknown error occurred'. >>> division (6,2) >>> division(3, a) 'Cannot divide anything but...

  • Use the switch structure to write a MATLAB program to compute the amount of money that...

    Use the switch structure to write a MATLAB program to compute the amount of money that accumulates in a savings account in one year. The program should accept the following input: the initial amount of money deposited in the account; the frequency of interest compounding (monthly, quarterly, semiannually, or annually); and the interest rate. Run your program for a $10000 initial deposit for each case; use a 4 percent interest rate. Compare the amounts of money that accumulate for each...

  • a. Create the logic for a program that calculates and displays the amount of money you...

    a. Create the logic for a program that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. Create a separate method to do the calculation and return the result to be displayed. b. Modify the program in Exercise 3a so that the main program prompts the user for the amount of money and passes it to the interest-calculating method. c. Modify the program in Exercise 3b so...

  • Write a program that calculates the amount of money that you must invest In a savings...

    Write a program that calculates the amount of money that you must invest In a savings account at a given interest rate for a given number of years to have a certain dollar amount at me end of the period Y our program will ask the user for the amount the user wants to have at the end of the term (future value). the number of years the user plans to let the money stay in the account, and the...

  • WRITE A COMPLETE PROGRAM IN C++ A. Ask users to input two positive integers a and...

    WRITE A COMPLETE PROGRAM IN C++ A. Ask users to input two positive integers a and b (a < b). You need to do error checking in this stage to make sure the input is correct. For example, a = 1, b = 50. B. Write a separate function, isEven() to list all even within [a, b] inclusive. C. n the main function, print a, b and the list of even numbers.

  • 14.Compound Interest hank account pays compound interest, it pays interest not only on the principal amount...

    14.Compound Interest hank account pays compound interest, it pays interest not only on the principal amount that was deposited into the account, but also on the interest that has accumulated over time. Suppose you want to deposit some money into a savings account, and let the account earn compound interest for a certain number of years. The formula for calculating the balance of the account afer a specified namber of years is The terms in the formula are A is...

  • Write a program that takes a file as input and checks whether or not the content...

    Write a program that takes a file as input and checks whether or not the content of the file is balanced. In the context of this assignment “balanced” means that your program will check to make sure that for each left bracket there is a closing right bracket. Examples:             [ ( ) ] { } à balanced.             [ ( ] ) { } à unbalanced. Here is the list of brackets/braces that program must support: (: left parentheses...

  • Hello, The C++ question is: ------------------------------------------------------------------------------- Write a program that takes as input 2 strings from...

    Hello, The C++ question is: ------------------------------------------------------------------------------- Write a program that takes as input 2 strings from the user. Then it determines if one string is a permutation of the other string. If the program answers "yes" to the previous question, meaning the two strings are permutations of each other, determine if each string has all unique characters. --------------------------------------------------------------------------------- I have completed the first part but I am unsure on how to also determine if each string is all unique characters...

  • Please I wish you use Python 3.7 for this problems. Q1. Write a program that receives...

    Please I wish you use Python 3.7 for this problems. Q1. Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he or she is finished providing inputs. After the user presses the enter key, the program should print the sum of the numbers and their average. Q2. The credit plan at TidBit Computer Store specifies a 10% down payment and an annual interest rate of...

  • Use C programming Make sure everything works well only upload Write a program that takes an...

    Use C programming Make sure everything works well only upload Write a program that takes an integer from standard input and prints all prime numbers that are smaller than it to standard output. Recall that a prime number is a natural number greater than 1 whose only positive divisors are 1 and itself. At the start of the program, prompt the user to input a number by printing "Input a number greater than 2:\n". If the user's input is less...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT