Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment# 1 part 1 : Description of the Problem: Write a program that receives three input values: an input value for a total amount in

Assignment#1 part 1:
Description of the Problem: Write a program that receives three input values: an input value for
a total amount in a deposit account as a double value, an annual interest rate, and number of
years. The program then calculates and displays the future investment amount using the following
formula:
fia = iia **(1+ mir )(12**y)
Where:
fia is Future Investment Amount,
iia is Initial Investment Amount,
mir is Monthly Interest Rate (i.e. Annual Interest Rate divided by 1200).
y Number of Years.
For example, if you enter an Initial Investment Amount of 100 as deposit amount and, an annual
interest rate of 4.25%, and number of years 2, the future investment amount fia in the end of two
years will be:
100**(1+4.251200)(2**12)=100**(1+4.251200)24=100**5.003542(24)=108.855359027416363
Execute your program using the following sample input values and provide your program output:
Enter investment amount iia: 8407.56
Enter annual interest rate in percentage: 5.5%
Enter number of years: 7
Future Investment Value is calculated is: $12345.007077220494
Hint:
use the Math pow (a,b) method to compute a raised to the power b.
Follow-up Program Assignment#1 part 2
Continue your code above to the following steps:
Your program should convert the final fia value to an integer number (e.g.
12345.007077220494 above) to an integer number, identified as fiai (e.g. fiai =12345).
Write code to separate digits of fiai value into its individual digits and print the digits
one on each line. For example, in the above case, digit1 appears on one line, followed
by digit 2 on the following line, and so on and finally digit5 on the last line.
Problem-Solving Tips for part2:
The FIAI final value consists of one integer, so you are using an int variable to represent it.
You will use a series of statements to "break down" the number into its individual digits, using
integer arithmetic with remainder (%) and division (??) calculations.
For example the fiai divided by 10000 gets the first digit. Why does this operation work?
Dividing an integer by an integer yields an integer result. Because the number input is five digits
long, dividing it by 10000 gives the leftmost digit (e.g. digit5).
For example, 4233910000 evaluates to 4 because 10000 divides into 42339 four times. The
remainder is truncated in integer arithmetic.
Change the number to a four-digit number, using the remainder operator to obtain the remainder
after the number is divided by 10000-in this case, the rightmost four digits.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

T Sql Fundamentals

Authors: Itzik Ben Gan

4th Edition

0138102104, 978-0138102104

More Books

Students also viewed these Databases questions