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.25/1200)(2*12)=100*(1+4.25/1200)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.
2
Follow-up Program Assignment#1 part 2
Continue your code above to the following steps:
1. 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).
2. 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 digit2 on the following line, and so on and finally digit5 on the last line.
Problem-Solving Tips for part2:
1. The FIAI final value consists of one integer, so you are using an int variable to represent it.
2. You will use a series of statements to break down the number into its individual digits, using
integer arithmetic with remainder (%) and division (/) calculations.
3. 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, 42339/10000 evaluates to 4 because 10000 divides into 42339 four times. The
remainder is truncated in integer arithmetic.
4. Change the number to a four-digit number, using the remainder operator to obtain the remainder
after the number is divided by 10000in this case, the rightmost four digits.
For example, 42339%10000 results in 2339.
5. Repeat this pattern of division and remainder calculations. Each time, the number used in the
division and remainder calculations is reduced by a factor of 10. The first digit is obtained by
dividing the five-digit number by 10000. Then, the variable containing the number is assigned the
remainder after the five-digit number is divided by 10000. After the number is changed to a four-
digit number, perform division and remainder calculations with 1000; after the number is changed
to a three-digit number, perform division and remainder calculations with 100; and so on.
Important
Be sure to follow the spacing, indentation conventions and brief comments.
Only basic concepts discussed during lectures up to this stage (i.e. chapter 1 and chapter 2) must
be used for programming Asiginment#1. The numerical values should not be converted to String
or characters.
Sample Output of Assigment#1:
The final program output using sample data set should appear as:
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
fiai is: 12345
fiai digits are:
digit1: 1
digit2: 2
digit3: 3
digit4: 4
digit5: 5
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

Database Systems For Advanced Applications 9th International Conference Dasfaa 2004 Jeju Island Korea March 2004 Proceedings Lncs 2973

Authors: YoonJoon Lee ,Jianzhong Li ,Kyu-Young Whang

2004th Edition

3540210474, 978-3540210474

More Books

Students also viewed these Databases questions

Question

25.0 m C B A 52.0 m 65.0 m

Answered: 1 week ago

Question

Does it avoid use of underlining?

Answered: 1 week ago