Question: In this task you have been given code that asks the user to enter 5 decimal numbers, and stores these in an array. This time
In this task you have been given code that asks the user to enter decimal numbers, and stores these in an array.
This time these numbers represent the balance of a bank account at monthly intervals. The first element in the array is the balance of the bank account at the start of the first month, the second element is the balance of the account at the start of the nd month, and so on
Your task is to analyse the data in the array and print out one of the following options:
"You are saving consistently, well done!" if the balance of the account consistently increases from month to month.
"Your savings are dwindling" if the balance of the account consistently decreases from month to month.
"Your savings have fluctuated" if the balance of the account does not consistently increase or decrease from month to month.
Hint :
To tell if the bank account is consistently increasing, you would need to confirm that the nd element is greater than the st the rd element is greater than the nd the th element is greater than the rd and the th element is greater than the th In other words, you need to compare every adjacent pair of elements in the array. You can do this as one big boolean expression. It's not that bad since there are only adjacent pairs to compare.
Hint :
Your approach for telling if the bank account is consistently decreasing would also focus on comparing adjacent pairs of elements in the array, and could again be done as one big boolean expression.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
